diff options
| author | Christian Tismer <tismer@stackless.com> | 2021-05-08 16:06:23 +0200 |
|---|---|---|
| committer | Christian Tismer <tismer@stackless.com> | 2021-08-18 01:20:04 +0200 |
| commit | 81e9cff884d6b03cdf64a5dd6ec6564d99177e0c (patch) | |
| tree | 9203d7cd8c2dd8829b5df32f06023c26cea5744b | |
| parent | 2530cb3f165ac02b8f7132e3f5ab4f7f6896dbd9 (diff) | |
py3.10-prep: Finally support Python 3.10
After the major problems are solved in
py3.10-prep: re-implement zip import
py3.10-prep: reset the type cache after feature switching
py3.10-prep: Fix parser.py for changed typing module
, there are only some minor changes left to do. One thing
is still not clear:
* Unsolved: In time_test.py, the last two tests work but
crash at shutdown.
It is not yet clear if this is a PySide or Python error.
This will crash Python 3.10 if not solved until the release.
[ChangeLog][PySide6] Support Python 3.10. This is by 99% solved.
Looking for a crash with unknown origin.
Fixes: PYSIDE-1436
Change-Id: I94cffa7ed16a2651e09924fe5babc188b1b4c2b8
Reviewed-by: Christian Tismer <tismer@stackless.com>
| -rw-r--r-- | build_scripts/config.py | 1 | ||||
| -rw-r--r-- | sources/pyside6/tests/QtWidgets/signature_test.py | 5 | ||||
| -rw-r--r-- | sources/shiboken6/libshiboken/pep384impl.cpp | 13 | ||||
| -rw-r--r-- | sources/shiboken6/libshiboken/pep384impl.h | 7 | ||||
| -rw-r--r-- | sources/shiboken6/libshiboken/sbkstring.cpp | 2 | ||||
| -rw-r--r-- | sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py | 1 | ||||
| -rw-r--r-- | sources/shiboken6/tests/samplebinding/time_test.py | 1 |
7 files changed, 19 insertions, 11 deletions
diff --git a/build_scripts/config.py b/build_scripts/config.py index ba89d04bd..3686f4ff0 100644 --- a/build_scripts/config.py +++ b/build_scripts/config.py @@ -91,6 +91,7 @@ class Config(object): 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', ] self.setup_script_dir = None diff --git a/sources/pyside6/tests/QtWidgets/signature_test.py b/sources/pyside6/tests/QtWidgets/signature_test.py index 94224c6ae..c507c2ca7 100644 --- a/sources/pyside6/tests/QtWidgets/signature_test.py +++ b/sources/pyside6/tests/QtWidgets/signature_test.py @@ -64,8 +64,9 @@ class PySideSignatureTest(unittest.TestCase): for thing in obj.__signature__: self.assertEqual(type(thing), inspect.Signature) sm = PySide6.QtWidgets.QApplication.__dict__["palette"] - self.assertFalse(callable(sm)) - self.assertEqual(sm.__func__, obj) + # PYSIDE-1436: staticmethod is a callable since Python 3.10 + # Instead of checking callable(sm), we check the type: + self.assertEqual(type(sm), staticmethod) self.assertTrue(hasattr(sm, "__signature__") and sm.__signature__ is not None) diff --git a/sources/shiboken6/libshiboken/pep384impl.cpp b/sources/shiboken6/libshiboken/pep384impl.cpp index 7678fe661..8ec562a78 100644 --- a/sources/shiboken6/libshiboken/pep384impl.cpp +++ b/sources/shiboken6/libshiboken/pep384impl.cpp @@ -758,14 +758,14 @@ _Pep_PrivateMangle(PyObject *self, PyObject *name) } Shiboken::AutoDecRef privateobj(PyObject_GetAttr( reinterpret_cast<PyObject *>(Py_TYPE(self)), Shiboken::PyMagicName::name())); -#ifndef Py_LIMITED_API - return _Py_Mangle(privateobj, name); -#else - // For some reason, _Py_Mangle is not in the Limited API. Why? - size_t plen = PyUnicode_GET_LENGTH(privateobj); + + // PYSIDE-1436: _Py_Mangle is no longer exposed; implement it always. + // The rest of this function is our own implementation of _Py_Mangle. + // Please compare the original function in compile.c . + size_t plen = PyUnicode_GET_LENGTH(privateobj.object()); /* Strip leading underscores from class name */ size_t ipriv = 0; - while (PyUnicode_READ_CHAR(privateobj, ipriv) == '_') + while (PyUnicode_READ_CHAR(privateobj.object(), ipriv) == '_') ipriv++; if (ipriv == plen) { Py_INCREF(name); @@ -794,7 +794,6 @@ _Pep_PrivateMangle(PyObject *self, PyObject *name) if (amount > big_stack) free(resbuf); return result; -#endif // else Py_LIMITED_API } /***************************************************************************** diff --git a/sources/shiboken6/libshiboken/pep384impl.h b/sources/shiboken6/libshiboken/pep384impl.h index 6d297bc7d..d326141d6 100644 --- a/sources/shiboken6/libshiboken/pep384impl.h +++ b/sources/shiboken6/libshiboken/pep384impl.h @@ -40,6 +40,11 @@ #ifndef PEP384IMPL_H #define PEP384IMPL_H +// PYSIDE-1436: Adapt to Python 3.10 +#if PY_VERSION_HEX < 0x030900A4 +# define Py_SET_REFCNT(obj, refcnt) ((Py_REFCNT(obj) = (refcnt)), (void)0) +#endif + extern "C" { @@ -322,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 < 0x0309FFFF) + PY_VERSION_HEX < 0x030AFFFF) #if !PYTHON_BUFFER_VERSION_COMPATIBLE # error Please check the buffer compatibility for this python version! #endif diff --git a/sources/shiboken6/libshiboken/sbkstring.cpp b/sources/shiboken6/libshiboken/sbkstring.cpp index 177b946fa..43654d589 100644 --- a/sources/shiboken6/libshiboken/sbkstring.cpp +++ b/sources/shiboken6/libshiboken/sbkstring.cpp @@ -219,7 +219,7 @@ static void finalizeStaticStrings() { auto &set = staticStrings(); for (PyObject *ob : set) { - Py_REFCNT(ob) = 1; + Py_SET_REFCNT(ob, 1); Py_DECREF(ob); } set.clear(); diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py index b377b1bef..ef9c8f0e2 100644 --- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py +++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py @@ -307,6 +307,7 @@ type_map.update({ "zero(object)": None, "zero(str)": "", "zero(typing.Any)": None, + "zero(Any)": None, }) type_map.update({ diff --git a/sources/shiboken6/tests/samplebinding/time_test.py b/sources/shiboken6/tests/samplebinding/time_test.py index 5552457ab..5fa36621d 100644 --- a/sources/shiboken6/tests/samplebinding/time_test.py +++ b/sources/shiboken6/tests/samplebinding/time_test.py @@ -131,6 +131,7 @@ class TimeTest(unittest.TestCase): result = time.somethingCompletelyDifferent(1, 2, ImplicitConv.CtorOne) self.assertEqual(result, Time.ThreeArgs) + # PYSIDE-1436: These tests crash at shutdown due to `assert(Not)?Equal`. def testCompareWithPythonTime(self): time = Time(12, 32, 5) py = datetime.time(12, 32, 5) |
