diff options
author | Sam Gross <colesbury@gmail.com> | 2024-04-11 19:00:54 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-11 19:00:54 (GMT) |
commit | 25f6ff5d3e92305659db62e7f7545f823f0dbd05 (patch) | |
tree | 3fe6dd2136780028874b6b3cde3ca8c4c903f033 /Lib/test/test_interpreters | |
parent | 39d381f91e93559011587d764c1895ee30efb741 (diff) | |
download | cpython-25f6ff5d3e92305659db62e7f7545f823f0dbd05.zip cpython-25f6ff5d3e92305659db62e7f7545f823f0dbd05.tar.gz cpython-25f6ff5d3e92305659db62e7f7545f823f0dbd05.tar.bz2 |
gh-117649: Raise ImportError for unsupported modules in free-threaded build (#117651)
The free-threaded build does not currently support the combination of
single-phase init modules and non-isolated subinterpreters. Ensure that
`check_multi_interp_extensions` is always `True` for subinterpreters in
the free-threaded build so that importing these modules raises an
`ImportError`.
Diffstat (limited to 'Lib/test/test_interpreters')
-rw-r--r-- | Lib/test/test_interpreters/test_api.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/Lib/test/test_interpreters/test_api.py b/Lib/test/test_interpreters/test_api.py index abf66a7..769bb7b 100644 --- a/Lib/test/test_interpreters/test_api.py +++ b/Lib/test/test_interpreters/test_api.py @@ -10,6 +10,7 @@ from test import support from test.support import import_helper # Raise SkipTest if subinterpreters not supported. _interpreters = import_helper.import_module('_xxsubinterpreters') +from test.support import Py_GIL_DISABLED from test.support import interpreters from test.support.interpreters import ( InterpreterError, InterpreterNotFoundError, ExecutionFailed, @@ -1162,7 +1163,7 @@ class LowLevelTests(TestBase): allow_exec=True, allow_threads=True, allow_daemon_threads=True, - check_multi_interp_extensions=False, + check_multi_interp_extensions=bool(Py_GIL_DISABLED), gil='shared', ), 'empty': types.SimpleNamespace( @@ -1361,6 +1362,7 @@ class LowLevelTests(TestBase): with self.subTest('custom'): orig = _interpreters.new_config('empty') orig.use_main_obmalloc = True + orig.check_multi_interp_extensions = bool(Py_GIL_DISABLED) orig.gil = 'shared' interpid = _interpreters.create(orig) config = _interpreters.get_config(interpid) @@ -1410,13 +1412,8 @@ class LowLevelTests(TestBase): with self.subTest('main'): expected = _interpreters.new_config('legacy') expected.gil = 'own' - interpid, *_ = _interpreters.get_main() - config = _interpreters.get_config(interpid) - self.assert_ns_equal(config, expected) - - with self.subTest('main'): - expected = _interpreters.new_config('legacy') - expected.gil = 'own' + if Py_GIL_DISABLED: + expected.check_multi_interp_extensions = False interpid, *_ = _interpreters.get_main() config = _interpreters.get_config(interpid) self.assert_ns_equal(config, expected) |