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

2013-10-18 Thread Roundup Robot
Roundup Robot added the comment: New changeset 76184b5339f2 by Brett Cannon in branch 'default': Issue #18416: Have importlib.machinery.PathFinder treat '' as the cwd http://hg.python.org/cpython/rev/76184b5339f2 -- nosy: +python-dev ___ Python

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

2013-10-18 Thread Brett Cannon
Brett Cannon added the comment: I went with option 1 (changed PathFinder to consider '' the cwd) which allowed me to flat-out remove the special-casing for '' in FileFinder. Thanks for the initial patch, Madison! -- resolution: - fixed stage: test needed - committed/rejected status:

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

2013-10-18 Thread Roundup Robot
Roundup Robot added the comment: New changeset 33844153cd02 by Brett Cannon in branch 'default': Issue #18416: Fix various os calls in importlib.machinery.FileFinder http://hg.python.org/cpython/rev/33844153cd02 -- ___ Python tracker

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

2013-10-17 Thread Brett Cannon
Changes by Brett Cannon br...@python.org: -- assignee: - brett.cannon ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18416 ___ ___

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

2013-08-12 Thread Madison May
Madison May added the comment: Here's a minor revision to that patch removing an unnecessary @skip_if_dont_write_bytecode decorator from the test I added to test_import.py. No docs changes are included in the current patch -- I'm guessing this should probably wait until we have all the

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

2013-08-12 Thread Madison May
Changes by Madison May madison@students.olin.edu: Added file: http://bugs.python.org/file31248/Issue18416_v2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18416 ___

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

2013-08-11 Thread Brett Cannon
Brett Cannon added the comment: To answer Eric's question: yes. Since no one seems to be screaming that sys.path be the only place to have the concept of a relative path, then let's use only absolute paths except in sys.path for ''. -- ___ Python

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

2013-08-11 Thread Madison May
Madison May added the comment: I'm currently leaning towards having sys.path_importer_cache store the actual directory name. Exactly what I meant by Creating a new entry in sys.path_importer_cache after changing directories and importing a new module, but expressed much more succinctly :)

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

2013-08-10 Thread Brett Cannon
Brett Cannon added the comment: I'm currently leaning towards having sys.path_importer_cache store the actual directory name. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18416 ___

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

2013-08-10 Thread Eric Snow
Eric Snow added the comment: I'm currently leaning towards having sys.path_importer_cache store the actual directory name. Makes sense to me. It the problem that sys.path will still have '' in it and it may be hard to figure out what it means (and how it maps to sys.path_importer_cache)?

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

2013-08-10 Thread Nick Coghlan
Nick Coghlan added the comment: It seems to me that by *not* doing that, we may have a bug if the cwd changes and the import machinery returns a stateful importer that remembers the path name. Using the actual filesystem path for everything other than sys.path sounds like a much better

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

2013-08-09 Thread Madison May
Madison May added the comment: I quickly ran the tests with each of the above edits to see what bits of the test suite would break. With option 1 (edits to PathFinder only): ``1 test failed: test_importlib`` With option 2 (edits to FileFinder only): ``3 tests failed: test_import

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

2013-08-08 Thread Brett Cannon
Brett Cannon added the comment: So this is bringing up a sticky situation that I ran across when initially implementing all of this: what should sys.path_importer_cache use as a key? '' would be what happens with Madison's option 3, and with option 1 it would be os.getcwd(). Now if you

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

2013-08-07 Thread Madison May
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

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

2013-08-06 Thread Brett Cannon
Brett Cannon added the comment: I actually meant FileFinder but PathFinder is a good point. In FileFinder you need to change ``self.path = path or '.'`` to use the cwd. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18416

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

2013-08-06 Thread Madison May
Madison May added the comment: A few days ago I tried the change: ``self.path = path or _os.cwd()``, but the problem didn't seem to resolve itself. ``./python -c import blah; print(blah.__file__)`` still returned a relative path on my system. The tie between FileFinder and the __file__

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

2013-08-06 Thread Nick Coghlan
Nick Coghlan added the comment: Make sure to run make to rebuild the frozen module - editing importlib._bootstrap.py involves a C style edit, build, test cycle rather than the typical Python edit, test cycle. -- ___ Python tracker

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

2013-08-06 Thread Madison May
Madison May added the comment: Thanks for the heads up, Nick. I've worked with _bootstrap.py before, so I'm familiar with the cycle. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18416

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

2013-08-06 Thread Nick Coghlan
Nick Coghlan added the comment: Figured it was worth mentioning, since I've been caught by forgetting that myself :) I suspect you're right that it's just a case of '.' passing the truth test, even though it still results in a relative path. -- ___

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

2013-08-02 Thread Madison May
Madison May added the comment: PathFinder or FileFinder? Changing PathFinder._path_importer_cache(cls, path) seems to fix the issue. See line 1302 in _bootstrap.py. if path == '': -path = '.' +path = _os.getcwd() $ touch blah.py; ./python -c import blah;

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

2013-07-10 Thread Ronald Oussoren
Ronald Oussoren added the comment: Isn't this because the first entry of sys.path is '' when python is started without a script? All other paths on sys.path are already absolute paths (tested with a relative path in $PYTHONPATH). If that's correct, just adding os.getcwd() instead of '' as the

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

2013-07-10 Thread Brett Cannon
Brett Cannon added the comment: That's exactly why it currently happens. What I would do is change importlib to just associate '' with os.getcwd() in FileFinder. That locks down where the module was found to an absolute path while still allowing '' to function as the cwd and be dynamically

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

2013-07-10 Thread Nick Coghlan
Nick Coghlan added the comment: Brett's plan sounds good to me. We should also check we make sure __main__.__file__ is always absolute. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18416

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

2013-07-09 Thread Brett Cannon
New submission from Brett Cannon: $ touch blah.py; ./python -c import blah; print(blah.__file__) ./blah.py Should really change that to be an absolute path since the file's location is not accurate if you call os.chdir(). -- components: Interpreter Core messages: 192772 nosy:

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

2013-07-09 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com: -- nosy: +Arfrever ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18416 ___

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

2013-07-09 Thread Brett Cannon
Changes by Brett Cannon br...@python.org: -- nosy: +ncoghlan ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18416 ___ ___ Python-bugs-list mailing