Nick Coghlan added the comment:

Ah, some glorious (in)consistency here:

$ cat > echo_file.py
print(__file__)

(2.7, old import system)
$ python -c "import echo_file"
echo_file.pyc
$ python -m "echo_file"
/home/ncoghlan/devel/play/echo_file.py
$ python echo_file.py
echo_file.py

(3.2, cache directories)
$ python3 -c "import echo_file"
echo_file.py
$ python3 -m "echo_file"
/home/ncoghlan/devel/play/echo_file.py
$ python3 echo_file.py
echo_file.py

(3.3, new import system)
$ ../py33/python -c "import echo_file"
./echo_file.py
$ ../py33/python -m "echo_file"
/home/ncoghlan/devel/play/echo_file.py
$ ../py33/python echo_file.py
echo_file.py

However, if we change Python's behaviour here, it's more likely to be in the 
direction of making __file__ reliably absolute, as allowing relative paths in 
__file__ can cause problems if the current directory ever changes. (I do wonder 
if this could be the reason nosetests doesn't work with -m, though).

----------
nosy: +brett.cannon
versions: +Python 3.3

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue16737>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to