[issue18416] Move to absolute file paths for module.__file__

Madison May report at bugs.python.org
Thu Aug 8 03:16:49 CEST 2013


Madison May added the comment:

Nick, it was definitely a good thing to mention.  I had to learn the "edit, build, test" cycle the hard way my first time.  It took me a good 15-20 minutes to figure out why none of my edits seemed to change anything :)


Anyhow, here's how I see the issue. It seems like we have three main options:

In option one, we only modify PathFinder._path_importer_cache().

         if path == '':
-            path = '.'
+            path = _os.getcwd()

This associates the cwd with FileFinder(cwd) in sys.path_importer_cache

In option two, we only modify FileFinder.__init__().

-        self.path = path or '.'
+        if not path or path == '.':
+            path = _os.getcwd()
+        self.path = path

This associates '.' with FileFinder(cwd) in sys.path_importer_cache.

In option three, we modify both PathFinder and FileFinder.  In PathFinder._path_importer_cache() we remove the line that reassigns path to '.' if path is the empty string.

-        if path == '':
-            path = '.'

In FileFinder.__init__(), we set path to _os.getcwd() if path is false.

-        self.path = path or '.'
+        self.path = path or _os.getcwd() 

This associates the empty string with FileFinder(cwd) in sys.path_importer_cache.

What are your thoughts? Which solution would you all support?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18416>
_______________________________________


More information about the Python-bugs-list mailing list