Message177932
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). |
|
Date |
User |
Action |
Args |
2012-12-22 10:12:00 | ncoghlan | set | recipients:
+ ncoghlan, brett.cannon, vinay.sajip, eric.araujo, serhiy.storchaka |
2012-12-22 10:12:00 | ncoghlan | set | messageid: <1356171120.76.0.156312188369.issue16737@psf.upfronthosting.co.za> |
2012-12-22 10:12:00 | ncoghlan | link | issue16737 messages |
2012-12-22 10:12:00 | ncoghlan | create | |
|