homepage

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 kgabor79
Recipients kgabor79
Date 2012年09月12日.15:32:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1347463942.49.0.408409423071.issue15931@psf.upfronthosting.co.za>
In-reply-to
Content
The attached script works in 2.6(.4) but not in 2.7(.3); the script cannot locate its own source code if invoked by relative path and work directory has changed. If line 8 uncommented, everything is fine due to caching. 
I think this is related to issue #4050 changes in inspect.py. 
~ kgabor$ python ./instest.py
None ./instest.py
Traceback (most recent call last):
 File "./instest.py", line 10, in <module>
 print inspect.getsourcefile(A), inspect.getfile(A),inspect.findsource(A)
 File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 529, in findsource
 raise IOError('source code not available')
IOError: source code not available
~ kgabor$ pwd
/Users/kgabor
~ kgabor$ python /Users/kgabor/instest.py
/Users/kgabor/instest.py /Users/kgabor/instest.py (['import inspect\n', 'import os\n', '\n', 'class A:\n', ' def __init__(self):\n', ' self.a=1\n', '\n', '#print inspect.getsourcefile(A),inspect.getfile(A),inspect.findsource(A)\n', "os.chdir('/')\n", 'print inspect.getsourcefile(A), inspect.getfile(A),inspect.findsource(A)\n'], 3)
History
Date User Action Args
2012年09月12日 15:32:22kgabor79setrecipients: + kgabor79
2012年09月12日 15:32:22kgabor79setmessageid: <1347463942.49.0.408409423071.issue15931@psf.upfronthosting.co.za>
2012年09月12日 15:32:21kgabor79linkissue15931 messages
2012年09月12日 15:32:21kgabor79create

AltStyle によって変換されたページ (->オリジナル) /