mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
bpo-42955: Add sys.modules_names (GH-24238)
Add sys.module_names, containing the list of the standard library module names.
This commit is contained in:
parent
879986d8a9
commit
db584bdad3
10 changed files with 305 additions and 275 deletions
|
|
@ -569,12 +569,23 @@ class CAPITest(unittest.TestCase):
|
|||
self.assertEqual(len(modules), total)
|
||||
|
||||
def test_fatal_error(self):
|
||||
# By default, stdlib extension modules are ignored,
|
||||
# but not test modules.
|
||||
expected = ('_testcapi',)
|
||||
not_expected = ('sys', 'builtins', '_imp', '_thread', '_weakref',
|
||||
'_io', 'marshal', '_signal', '_abc')
|
||||
code = 'import _testcapi; _testcapi.fatal_error(b"MESSAGE")'
|
||||
not_expected = ('sys',)
|
||||
code = 'import _testcapi, sys; _testcapi.fatal_error(b"MESSAGE")'
|
||||
self.check_fatal_error(code, expected, not_expected)
|
||||
|
||||
# Mark _testcapi as stdlib module, but not sys
|
||||
expected = ('sys',)
|
||||
not_expected = ('_testcapi',)
|
||||
code = textwrap.dedent('''
|
||||
import _testcapi, sys
|
||||
sys.module_names = frozenset({"_testcapi"})
|
||||
_testcapi.fatal_error(b"MESSAGE")
|
||||
''')
|
||||
self.check_fatal_error(code, expected)
|
||||
|
||||
|
||||
class TestPendingCalls(unittest.TestCase):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue