Skip to content

Commit a5312df

Browse files
committed
MNT: support py310
There was a change in the CPython c-api to change `Py_TYPE` from a macro to an inline function (python/cpython#20290). This requires a change to using `Py_SET_TYPE` which was introduced on py39a4.
1 parent 729fd54 commit a5312df

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/module.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111

1212
#define PYCURL_VERSION_PREFIX "PycURL/" PYCURL_VERSION_STRING
1313

14+
/* Introduced in https://github.com/python/cpython/commit/d2ec81a8c99796b51fb8c49b77a7fe369863226f */
15+
#if PY_VERSION_HEX < 0x030900a4
16+
#define Py_SET_TYPE(obj, typ) (Py_TYPE(obj) = typ)
17+
#endif
18+
19+
1420
PYCURL_INTERNAL char *empty_keywords[] = { NULL };
1521

1622
PYCURL_INTERNAL PyObject *bytesio = NULL;
@@ -372,9 +378,9 @@ initpycurl(void)
372378
p_Curl_Type = &Curl_Type;
373379
p_CurlMulti_Type = &CurlMulti_Type;
374380
p_CurlShare_Type = &CurlShare_Type;
375-
Py_TYPE(&Curl_Type) = &PyType_Type;
376-
Py_TYPE(&CurlMulti_Type) = &PyType_Type;
377-
Py_TYPE(&CurlShare_Type) = &PyType_Type;
381+
Py_SET_TYPE(&Curl_Type, &PyType_Type);
382+
Py_SET_TYPE(&CurlMulti_Type, &PyType_Type);
383+
Py_SET_TYPE(&CurlShare_Type, &PyType_Type);
378384

379385
/* Create the module and add the functions */
380386
if (PyType_Ready(&Curl_Type) < 0)

0 commit comments

Comments
 (0)