diff options
| author | Barry Warsaw <barry@python.org> | 2010-05-18 14:15:20 (GMT) | 
|---|---|---|
| committer | Barry Warsaw <barry@python.org> | 2010-05-18 14:15:20 (GMT) | 
| commit | 04b5684d002de5e3eb4232bb287c6884afb61bf3 (patch) | |
| tree | 4a7c6928b97e00d09015b286153dfaf9cf7b7efb /Lib/importlib/_bootstrap.py | |
| parent | 2b80fa693914dcfe7983767328d0b545e0fd4c0e (diff) | |
| download | cpython-04b5684d002de5e3eb4232bb287c6884afb61bf3.zip cpython-04b5684d002de5e3eb4232bb287c6884afb61bf3.tar.gz cpython-04b5684d002de5e3eb4232bb287c6884afb61bf3.tar.bz2  | |
Repair test failure.  Bug 8727.
Diffstat (limited to 'Lib/importlib/_bootstrap.py')
| -rw-r--r-- | Lib/importlib/_bootstrap.py | 12 | 
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index 30d5251..511f7dd 100644 --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -494,8 +494,16 @@ class _PyPycFileLoader(PyPycLoader, _PyFileLoader):          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  | 
