diff options
author | Christian Tismer <tismer@stackless.com> | 2020-06-18 14:11:14 +0200 |
---|---|---|
committer | Christian Tismer <tismer@stackless.com> | 2020-08-19 10:31:58 +0200 |
commit | 401f4ff22833f2be900d9a6d8887e7dae7b07011 (patch) | |
tree | 903bdcdee29131b59c78a2779379a8cc0813a43a /sources/shiboken2/libshiboken | |
parent | 3f7bb2243ab294e6daf48ac567faef5468b3477d (diff) |
support Python 3.9
This was merged with "WIP: Enable support for Python 3.9".
There were minor problems, only.
Thanks Cristian for adding cosmetic changes which should already
have been applied in Python 3.8 or earlier.
Change-Id: Id5e8696d9cfb7192243ad44c93e9f2cf347d6a7c
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken2/libshiboken')
-rw-r--r-- | sources/shiboken2/libshiboken/basewrapper.cpp | 2 | ||||
-rw-r--r-- | sources/shiboken2/libshiboken/pep384impl.cpp | 4 | ||||
-rw-r--r-- | sources/shiboken2/libshiboken/pep384impl.h | 30 | ||||
-rw-r--r-- | sources/shiboken2/libshiboken/threadstatesaver.cpp | 4 |
4 files changed, 25 insertions, 15 deletions
diff --git a/sources/shiboken2/libshiboken/basewrapper.cpp b/sources/shiboken2/libshiboken/basewrapper.cpp index c3c16cb02..1960e5932 100644 --- a/sources/shiboken2/libshiboken/basewrapper.cpp +++ b/sources/shiboken2/libshiboken/basewrapper.cpp @@ -881,7 +881,9 @@ void init() Conversions::init(); +#if PY_VERSION_HEX < 0x03070000 PyEval_InitThreads(); +#endif //Init private data Pep384_Init(); diff --git a/sources/shiboken2/libshiboken/pep384impl.cpp b/sources/shiboken2/libshiboken/pep384impl.cpp index 57d3de261..6e4926370 100644 --- a/sources/shiboken2/libshiboken/pep384impl.cpp +++ b/sources/shiboken2/libshiboken/pep384impl.cpp @@ -319,9 +319,9 @@ Pep_GetVerboseFlag() #ifdef Py_LIMITED_API int -PepCode_Get(PyCodeObject *co, const char *name) +PepCode_Get(PepCodeObject *co, const char *name) { - PyObject *ob = (PyObject *)co; + PyObject *ob = reinterpret_cast<PyObject *>(co); PyObject *ob_ret; int ret = -1; diff --git a/sources/shiboken2/libshiboken/pep384impl.h b/sources/shiboken2/libshiboken/pep384impl.h index 973cf06ce..4b3e32ea2 100644 --- a/sources/shiboken2/libshiboken/pep384impl.h +++ b/sources/shiboken2/libshiboken/pep384impl.h @@ -327,7 +327,7 @@ LIBSHIBOKEN_API PyObject *PyRun_String(const char *, int, PyObject *, PyObject * // But this is no problem as we check it's validity for every version. #define PYTHON_BUFFER_VERSION_COMPATIBLE (PY_VERSION_HEX >= 0x03030000 && \ - PY_VERSION_HEX < 0x0308FFFF) + PY_VERSION_HEX < 0x0309FFFF) #if !PYTHON_BUFFER_VERSION_COMPATIBLE # error Please check the buffer compatibility for this python version! #endif @@ -411,23 +411,27 @@ LIBSHIBOKEN_API PyObject *PyMethod_Self(PyObject *); /* Bytecode object */ // we have to grab the code object from python -typedef struct _code PyCodeObject; +typedef struct _code PepCodeObject; -LIBSHIBOKEN_API int PepCode_Get(PyCodeObject *co, const char *name); +LIBSHIBOKEN_API int PepCode_Get(PepCodeObject *co, const char *name); -#define PepCode_GET_FLAGS(o) PepCode_Get(o, "co_flags") -#define PepCode_GET_ARGCOUNT(o) PepCode_Get(o, "co_argcount") +# define PepCode_GET_FLAGS(o) PepCode_Get(o, "co_flags") +# define PepCode_GET_ARGCOUNT(o) PepCode_Get(o, "co_argcount") /* Masks for co_flags above */ -#define CO_OPTIMIZED 0x0001 -#define CO_NEWLOCALS 0x0002 -#define CO_VARARGS 0x0004 -#define CO_VARKEYWORDS 0x0008 -#define CO_NESTED 0x0010 -#define CO_GENERATOR 0x0020 +# define CO_OPTIMIZED 0x0001 +# define CO_NEWLOCALS 0x0002 +# define CO_VARARGS 0x0004 +# define CO_VARKEYWORDS 0x0008 +# define CO_NESTED 0x0010 +# define CO_GENERATOR 0x0020 + #else -#define PepCode_GET_FLAGS(o) ((o)->co_flags) -#define PepCode_GET_ARGCOUNT(o) ((o)->co_argcount) + +# define PepCodeObject PyCodeObject +# define PepCode_GET_FLAGS(o) ((o)->co_flags) +# define PepCode_GET_ARGCOUNT(o) ((o)->co_argcount) + #endif /***************************************************************************** diff --git a/sources/shiboken2/libshiboken/threadstatesaver.cpp b/sources/shiboken2/libshiboken/threadstatesaver.cpp index 0d19528f9..085535fd7 100644 --- a/sources/shiboken2/libshiboken/threadstatesaver.cpp +++ b/sources/shiboken2/libshiboken/threadstatesaver.cpp @@ -51,7 +51,11 @@ ThreadStateSaver::~ThreadStateSaver() void ThreadStateSaver::save() { +#if PY_VERSION_HEX >= 0x0309000 + if (Py_IsInitialized()) +#else if (PyEval_ThreadsInitialized()) +#endif m_threadState = PyEval_SaveThread(); } |