diff options
author | Brett Cannon <brett@python.org> | 2012-04-27 19:30:58 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2012-04-27 19:30:58 (GMT) |
commit | aa93642a35ed570ba91a80c583df2c8a383686d6 (patch) | |
tree | ba6049cf83600cb3afe6d9e8d52c0b9480b5b22b /Lib/runpy.py | |
parent | 9e66ac683cce9f6e4abda7d01836dab70eeefb49 (diff) | |
download | cpython-aa93642a35ed570ba91a80c583df2c8a383686d6.zip cpython-aa93642a35ed570ba91a80c583df2c8a383686d6.tar.gz cpython-aa93642a35ed570ba91a80c583df2c8a383686d6.tar.bz2 |
Issue #14605: Use None in sys.path_importer_cache to represent no
finder instead of using some (now non-existent) implicit finder.
Diffstat (limited to 'Lib/runpy.py')
-rw-r--r-- | Lib/runpy.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/Lib/runpy.py b/Lib/runpy.py index f826e04..71c175f 100644 --- a/Lib/runpy.py +++ b/Lib/runpy.py @@ -9,6 +9,7 @@ importers when locating support scripts as well as when importing modules. # Written by Nick Coghlan <ncoghlan at gmail.com> # to implement PEP 338 (Executing Modules as Scripts) + import os import sys import imp @@ -206,11 +207,7 @@ def _get_importer(path_name): except ImportError: pass else: - # The following check looks a bit odd. The trick is that - # NullImporter throws ImportError if the supplied path is a - # *valid* directory entry (and hence able to be handled - # by the standard import machinery) - importer = imp.NullImporter(path_name) + importer = None cache[path_name] = importer return importer @@ -237,7 +234,7 @@ def run_path(path_name, init_globals=None, run_name=None): if run_name is None: run_name = "<run_path>" importer = _get_importer(path_name) - if isinstance(importer, imp.NullImporter): + if isinstance(importer, (type(None), imp.NullImporter)): # Not a valid sys.path entry, so run the code directly # execfile() doesn't help as we want to allow compiled files code = _get_code_from_file(path_name) |