diff options
| author | Christian Tismer <tismer@stackless.com> | 2023-02-14 14:46:22 +0100 |
|---|---|---|
| committer | Christian Tismer <tismer@stackless.com> | 2023-10-09 08:54:27 +0200 |
| commit | 441ffbd4fc622e67acd81e9c1c6d3a0b0fbcacf0 (patch) | |
| tree | 83226e3bccf205f6a941c53ce3698c88f99b7935 /sources/pyside6/tests/pysidetest/enum_test.py | |
| parent | 92a4a2a0ed7a8a391406030d1db813de7dd31429 (diff) | |
Support running PySide on Python 3.12
Builtin types no longer have tp_dict set. We need to
use PyType_GetDict, instead. This works without Limited API
at the moment.
With some great cheating, this works with Limited API, too.
We emulate PyType_GetDict by tp_dict if that is not 0.
Otherwise we create an empty dict.
Some small changes to Exception handling and longer
warm-up in leaking tests were found, too.
Pick-to: 6.6 6.5 6.2
Task-number: PYSIDE-2230
Change-Id: I8a56de6208ec00979255b39b5784dfc9b4b92def
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside6/tests/pysidetest/enum_test.py')
| -rw-r--r-- | sources/pyside6/tests/pysidetest/enum_test.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/sources/pyside6/tests/pysidetest/enum_test.py b/sources/pyside6/tests/pysidetest/enum_test.py index 0036eb764..189ef60c1 100644 --- a/sources/pyside6/tests/pysidetest/enum_test.py +++ b/sources/pyside6/tests/pysidetest/enum_test.py @@ -71,6 +71,7 @@ class InvestigateOpcodesTest(unittest.TestCase): _sin = sys.implementation.name @unittest.skipIf(hasattr(sys.flags, "nogil"), f"{_sin} has different opcodes") def testByteCode(self): + import dis # opname, opcode, arg result_1 = [('LOAD_GLOBAL', 116, 0), ('LOAD_ATTR', 106, 1), @@ -94,7 +95,7 @@ class InvestigateOpcodesTest(unittest.TestCase): ('LOAD_CONST', 100, 0), ('RETURN_VALUE', 83, None)] - if sys.version_info[:2] >= (3, 11): + if sys.version_info[:2] == (3, 11): # Note: Python 3.11 is a bit more complex because it can optimize itself. # Opcodes are a bit different, and a hidden second code object is used. # We investigate this a bit, because we want to be warned when things change. @@ -158,6 +159,22 @@ class InvestigateOpcodesTest(unittest.TestCase): self.assertEqual(self.read_code(self.probe_function2, adaptive=True), result_3) self.assertEqual(self.get_sizes(self.probe_function2, adaptive=True), sizes_3) + if sys.version_info[:2] >= (3, 12): + + result_1 = [('RESUME', 151, 0), + ('LOAD_GLOBAL', 116, 0), + ('LOAD_ATTR', 106, 2), + ('STORE_FAST', 125, 1), + ('RETURN_CONST', 121, 0)] + + result_2 = [('RESUME', 151, 0), + ('LOAD_GLOBAL', 116, 1), + ('LOAD_ATTR', 106, 2), + ('CALL', 171, 0), + ('STORE_FAST', 125, 1), + ('RETURN_CONST', 121, 0)] + + self.assertEqual(self.read_code(self.probe_function1), result_1) self.assertEqual(self.read_code(self.probe_function2), result_2) |
