[Python-checkins] r81290 - in python/branches/py3k/Lib: importlib/_bootstrap.py importlib/test/source/test_file_loader.py test/test_import.py
barry.warsaw
python-checkins at python.org
Tue May 18 16:15:20 CEST 2010
Author: barry.warsaw
Date: Tue May 18 16:15:20 2010
New Revision: 81290
Log:
Repair test failure. Bug 8727.
Modified:
python/branches/py3k/Lib/importlib/_bootstrap.py
python/branches/py3k/Lib/importlib/test/source/test_file_loader.py
python/branches/py3k/Lib/test/test_import.py
Modified: python/branches/py3k/Lib/importlib/_bootstrap.py
==============================================================================
--- python/branches/py3k/Lib/importlib/_bootstrap.py (original)
+++ python/branches/py3k/Lib/importlib/_bootstrap.py Tue May 18 16:15:20 2010
@@ -494,8 +494,16 @@
if ext_type == imp.PY_COMPILED:
# We don't really care what the extension on self._base_path is,
# as long as it has exactly one dot.
- bytecode_path = imp.cache_from_source(self._base_path + '.py')
- return (bytecode_path if _path_exists(bytecode_path) else None)
+ source_path = self._base_path + '.py'
+ pycache_path = imp.cache_from_source(source_path)
+ legacy_path = self._base_path + '.pyc'
+ # The rule is: if the source file exists, then Python always uses
+ # the __pycache__/foo.<tag>.pyc file. If the source file does not
+ # exist, then Python uses the legacy path.
+ pyc_path = (pycache_path
+ if _path_exists(source_path)
+ else legacy_path)
+ return (pyc_path if _path_exists(pyc_path) else None)
return super()._find_path(ext_type)
@_check_name
Modified: python/branches/py3k/Lib/importlib/test/source/test_file_loader.py
==============================================================================
--- python/branches/py3k/Lib/importlib/test/source/test_file_loader.py (original)
+++ python/branches/py3k/Lib/importlib/test/source/test_file_loader.py Tue May 18 16:15:20 2010
@@ -10,6 +10,8 @@
import sys
import unittest
+from test.support import make_legacy_pyc
+
class SimpleTest(unittest.TestCase):
@@ -136,6 +138,7 @@
file.write(new_bc)
if del_source:
os.unlink(mapping[name])
+ make_legacy_pyc(mapping[name])
return bytecode_path
@source_util.writes_bytecode_files
Modified: python/branches/py3k/Lib/test/test_import.py
==============================================================================
--- python/branches/py3k/Lib/test/test_import.py (original)
+++ python/branches/py3k/Lib/test/test_import.py Tue May 18 16:15:20 2010
@@ -142,7 +142,6 @@
self.assertIs(orig_path, new_os.path)
self.assertIsNot(orig_getenv, new_os.getenv)
- @unittest.expectedFailure # Issue 8727 is tracking the fix.
def test_module_with_large_stack(self, module='longlist'):
# Regression test for http://bugs.python.org/issue561858.
filename = module + '.py'
More information about the Python-checkins
mailing list