summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2020-06-02 12:55:49 +0200
committerArmin Rigo <arigo@tunes.org>2020-06-02 12:55:49 +0200
commitfc1d60bfb4a1e8ac58126ff4df672d0f8483c721 (patch)
tree2a6f87c332775ca1ca5798c4e63f6915c76b3385
parent82389a693860fa1add7ced57334f9b18c7f04d0e (diff)
downloadcffi-fc1d60bfb4a1e8ac58126ff4df672d0f8483c721.tar.gz
Issue #458
py3.10 support
-rw-r--r--c/_cffi_backend.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
index 5174648..b3c1c86 100644
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -111,6 +111,9 @@
# define PyText_InternInPlace PyUnicode_InternInPlace
# define PyText_InternFromString PyUnicode_InternFromString
# define PyIntOrLong_Check PyLong_Check
+# if PY_VERSION_HEX < 0x030900a4
+# define Py_SET_REFCNT(obj, val) (Py_REFCNT(obj) = (val))
+# endif
#else
# define STR_OR_BYTES "str"
# define PyText_Type PyString_Type
@@ -404,10 +407,10 @@ ctypedescr_dealloc(CTypeDescrObject *ct)
if (ct->ct_unique_key != NULL) {
/* revive dead object temporarily for DelItem */
- Py_REFCNT(ct) = 43;
+ Py_SET_REFCNT(ct, 43);
PyDict_DelItem(unique_cache, ct->ct_unique_key);
assert(Py_REFCNT(ct) == 42);
- Py_REFCNT(ct) = 0;
+ Py_SET_REFCNT(ct, 0);
Py_DECREF(ct->ct_unique_key);
}
Py_XDECREF(ct->ct_itemdescr);