[Python-checkins] cpython: Issue #18416: Fix various os calls in importlib.machinery.FileFinder

brett.cannon python-checkins at python.org
Fri Oct 18 18:01:15 CEST 2013


http://hg.python.org/cpython/rev/33844153cd02
changeset:   86438:33844153cd02
user:        Brett Cannon <brett at python.org>
date:        Fri Oct 18 12:01:06 2013 -0400
summary:
  Issue #18416: Fix various os calls in importlib.machinery.FileFinder
now that self.path is no longer forced to '.'.

files:
  Lib/importlib/_bootstrap.py |     4 +-
  Python/importlib.h          |  1554 +++++++++++-----------
  2 files changed, 780 insertions(+), 778 deletions(-)


diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -1390,7 +1390,7 @@
         is_namespace = False
         tail_module = fullname.rpartition('.')[2]
         try:
-            mtime = _os.stat(self.path).st_mtime
+            mtime = _os.stat(self.path or _os.getcwd()).st_mtime
         except OSError:
             mtime = -1
         if mtime != self._path_mtime:
@@ -1432,7 +1432,7 @@
         """Fill the cache of potential modules and packages for this directory."""
         path = self.path
         try:
-            contents = _os.listdir(path)
+            contents = _os.listdir(path or _os.getcwd())
         except (FileNotFoundError, PermissionError, NotADirectoryError):
             # Directory has either been removed, turned into a file, or made
             # unreadable.
diff --git a/Python/importlib.h b/Python/importlib.h
--- a/Python/importlib.h
+++ b/Python/importlib.h
[stripped]

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list