Skip to content

Commit 3642ffe

Browse files
committed
Use Py_SET_TYPE for python 3.11 compatibility
1 parent 1f97c07 commit 3642ffe

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

iconvmodule.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,13 @@ PyInit_iconv(void)
163163
{
164164
PyObject *m, *d;
165165

166-
Py_TYPE(&Iconv_Type) = &PyType_Type;
166+
#ifdef Py_SET_TYPE
167+
// Available since python 3.9, required since python 3.11
168+
Py_SET_TYPE(&Iconv_Type, &PyType_Type);
169+
#else
170+
// Fallback for python 3.6, 3.7 and 3.8
171+
Py_TYPE(&Iconv_Type) = &PyType_Type;
172+
#endif
167173
if (PyType_Ready(&Iconv_Type) < 0) {
168174
return NULL;
169175
}

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="python-iconv",
5-
version="1.1.1",
5+
version="1.1.2",
66
description="iconv-based Unicode converter",
77
author="Bodo Graumann",
88
author_email="mail@bodograumann.de",

0 commit comments

Comments
 (0)