summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_imp.py
diff options
context:
space:
mode:
authorNina Zakharenko <nzakharenko@gmail.com>2019-02-05 00:56:26 (GMT)
committerBarry Warsaw <barry@python.org>2019-02-05 00:56:26 (GMT)
commit69091cb497b2f0fe7e2789b30b43cf78caf9de9b (patch)
tree60e8125f1d1a74a77ffef29d97eed71e8de13383 /Lib/test/test_imp.py
parent89427cd0feae25bbc8693abdccfa6a8c81a2689c (diff)
downloadcpython-69091cb497b2f0fe7e2789b30b43cf78caf9de9b.zip
cpython-69091cb497b2f0fe7e2789b30b43cf78caf9de9b.tar.gz
cpython-69091cb497b2f0fe7e2789b30b43cf78caf9de9b.tar.bz2
bpo-35321: Set the spec origin to frozen in frozen modules (#11732)
* bpo-35321: Set the spec origin to frozen in frozen modules This fix correctly sets the spec origin to "frozen" for the _frozen_importlib module. Note that the origin was already correctly set in _frozen_importlib_external. * 📜🤖 Added by blurb_it.
Diffstat (limited to 'Lib/test/test_imp.py')
-rw-r--r--Lib/test/test_imp.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py
index bb0144b..fe394dc 100644
--- a/Lib/test/test_imp.py
+++ b/Lib/test/test_imp.py
@@ -332,6 +332,17 @@ class ImportTests(unittest.TestCase):
with self.assertRaises(TypeError):
create_dynamic(BadSpec())
+ def test_issue_35321(self):
+ # Both _frozen_importlib and _frozen_importlib_external
+ # should have a spec origin of "frozen" and
+ # no need to clean up imports in this case.
+
+ import _frozen_importlib_external
+ self.assertEqual(_frozen_importlib_external.__spec__.origin, "frozen")
+
+ import _frozen_importlib
+ self.assertEqual(_frozen_importlib.__spec__.origin, "frozen")
+
def test_source_hash(self):
self.assertEqual(_imp.source_hash(42, b'hi'), b'\xc6\xe7Z\r\x03:}\xab')
self.assertEqual(_imp.source_hash(43, b'hi'), b'\x85\x9765\xf8\x9a\x8b9')