This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients brett.cannon, eric.araujo, ncoghlan, serhiy.storchaka, vinay.sajip
Date 2012-12-22.10:12:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1356171120.76.0.156312188369.issue16737@psf.upfronthosting.co.za>
In-reply-to
Content
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).
History
Date User Action Args
2012-12-22 10:12:00ncoghlansetrecipients: + ncoghlan, brett.cannon, vinay.sajip, eric.araujo, serhiy.storchaka
2012-12-22 10:12:00ncoghlansetmessageid: <1356171120.76.0.156312188369.issue16737@psf.upfronthosting.co.za>
2012-12-22 10:12:00ncoghlanlinkissue16737 messages
2012-12-22 10:12:00ncoghlancreate