Skip to content

Commit d1b1868

Browse files
Default to using _imp.get_frozen_object().
1 parent f86dcd5 commit d1b1868

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Lib/test/test_importlib/frozen/test_finder.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
machinery = util.import_importlib('importlib.machinery')
55

6+
import _imp
67
import marshal
78
import os.path
89
import unittest
@@ -11,14 +12,18 @@
1112
from test.support import import_helper, REPO_ROOT, STDLIB_DIR
1213

1314

14-
def get_frozen_code(name, source=None, ispkg=False):
15+
def get_frozen_code(name, source=None, ispkg=False, *, useimp=True):
1516
"""Return the code object for the given module.
1617
1718
This should match the data stored in the frozen .h file used
1819
for the module.
1920
2021
"source" is the original module name or a .py filename.
2122
"""
23+
if useimp:
24+
with import_helper.frozen_modules():
25+
return _imp.get_frozen_object(name)
26+
2227
if not source:
2328
source = name
2429
else:

0 commit comments

Comments
 (0)