diff -r 8d6909ab6844 Lib/importlib/test/source/test_abc_loader.py --- a/Lib/importlib/test/source/test_abc_loader.py Tue Jun 05 16:48:38 2012 +0100 +++ b/Lib/importlib/test/source/test_abc_loader.py Thu Jun 07 18:32:21 2012 +0100 @@ -457,6 +457,22 @@ mtime = importlib._r_long(mock.module_bytecode[name][4:8]) self.assertEqual(mtime, PyPycLoaderMock.default_mtime) + @source_util.writes_bytecode_files + def test_pyc_compatibility(self): + name = 'foo' + with source_util.create_modules(name) as fpath: + loader = importlib.machinery.SourceFileLoader(name, fpath[name]) + module = loader.load_module(name) + bytecode_path = module.__cached__ + with open(bytecode_path, 'rb') as f: + cached_data = f.read() + mock = PyPycLoaderMock({name: fpath[name]}, + {name: {'path': bytecode_path}}) + mock.module_bytecode[name] = cached_data + del sys.modules[name] + mock.load_module(name) + self.assertEqual(mock.module_bytecode[name], cached_data) + class BadBytecodeFailureTests(unittest.TestCase):