classification
Title: Behaviour change in runpy for __file__ attributes between 3.2 and 3.3
Type: Stage:
Components: Versions: Python 3.3
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: brett.cannon, georg.brandl, ncoghlan
Priority: normal Keywords:

Created on 2012-07-18 11:12 by ncoghlan, last changed 2012-07-18 11:12 by ncoghlan. This issue is now closed.

Messages (1)
msg165754 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2012-07-18 11:12
Directory setup: linkdir is a symlink to realdir

$ python3 -c "import sys; sys.path.insert(0, 'linkdir'); import runpy; print(runpy.run_module('foo')['__file__'])"
/home/ncoghlan/devel/play/realdir/foo.py
$ ../py3k/python -c "import sys; sys.path.insert(0, 'linkdir'); import runpy; print(runpy.run_module('foo')['__file__'])"
/home/ncoghlan/devel/play/linkdir/foo.py

The culprit is pkgutil - the import emulation includes a realpath() call. Looking at the log, this dates from PJE's consolidation of the various import emulations back in 2006, with no specific rationale given.

Since this was only in the emulation, and nothing else broke when we took it out (indeed, it was the cause of test failures in 3.2, when it altered the __file__ values in ways the test wasn't expecting), I'm just creating and closing this issue to note that yes, I'm aware this has changed, but no, I don't consider it a problem, as it just brings pkgutil into line with the behaviour of normal imports.
History
Date User Action Args
2012-07-18 11:12:59ncoghlansetstatus: open -> closed
resolution: works for me
2012-07-18 11:12:05ncoghlancreate