[issue415492] Compiler generates relative filenames

Nick Coghlan report at bugs.python.org
Mon Oct 17 01:01:05 CEST 2011


Nick Coghlan <ncoghlan at gmail.com> added the comment:

It's fairly easy to check this is still a problem:

$ ./python
Python 3.3.0a0 (default:a06ef7ab7321, Sep 22 2011, 13:41:29) 
[GCC 4.6.0 20110603 (Red Hat 4.6.0-10)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import setup
>>> setup.__file__
'setup.py'

That's a relative path rather than an absolute one. If you edit sys.path to use '.' instead of '', it becomes clear that the import machinery is just doing a blind join of the sys.path entry with the relative location of the file:

>>> del sys.modules['setup']
>>> sys.path[0] = '.'
>>> import setup
>>> setup.__file__
'./setup.py'

----------
nosy: +brett.cannon, ncoghlan
resolution: fixed -> 
status: closed -> open

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


More information about the Python-bugs-list mailing list