summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/test
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2012-07-02 18:35:34 (GMT)
committerBrett Cannon <brett@python.org>2012-07-02 18:35:34 (GMT)
commit1e331560eea62c78ec189f2b72b59864ee315ddc (patch)
tree1d87381377f9e8d61439dacc74d56d516344df1c /Lib/importlib/test
parentd57caf36bd4f261b5d1e7ba758001fe5b6416daf (diff)
downloadcpython-1e331560eea62c78ec189f2b72b59864ee315ddc.zip
cpython-1e331560eea62c78ec189f2b72b59864ee315ddc.tar.gz
cpython-1e331560eea62c78ec189f2b72b59864ee315ddc.tar.bz2
Closes #15030: Make importlib.abc.PyPycLoader respect the new .pyc
file size header field. Thanks to Marc Abramowitz and Ronan Lamy for helping out with various parts of the patch.
Diffstat (limited to 'Lib/importlib/test')
-rw-r--r--Lib/importlib/test/source/test_abc_loader.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/importlib/test/source/test_abc_loader.py b/Lib/importlib/test/source/test_abc_loader.py
index 27babb9..afcaad0 100644
--- a/Lib/importlib/test/source/test_abc_loader.py
+++ b/Lib/importlib/test/source/test_abc_loader.py
@@ -148,11 +148,12 @@ class PyPycLoaderMock(abc.PyPycLoader, PyLoaderMock):
self.bytecode_to_path[name] = data['path']
magic = data.get('magic', imp.get_magic())
mtime = importlib._w_long(data.get('mtime', self.default_mtime))
+ source_size = importlib._w_long(len(self.source) & 0xFFFFFFFF)
if 'bc' in data:
bc = data['bc']
else:
bc = self.compile_bc(name)
- self.module_bytecode[name] = magic + mtime + bc
+ self.module_bytecode[name] = magic + mtime + source_size + bc
def compile_bc(self, name):
source_path = self.module_paths.get(name, '<test>') or '<test>'
@@ -344,7 +345,10 @@ class PyPycLoaderTests(PyLoaderTests):
self.assertEqual(magic, imp.get_magic())
mtime = importlib._r_long(mock.module_bytecode[name][4:8])
self.assertEqual(mtime, 1)
- bc = mock.module_bytecode[name][8:]
+ source_size = mock.module_bytecode[name][8:12]
+ self.assertEqual(len(mock.source) & 0xFFFFFFFF,
+ importlib._r_long(source_size))
+ bc = mock.module_bytecode[name][12:]
self.assertEqual(bc, mock.compile_bc(name))
def test_module(self):