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 exarkun
Recipients exarkun, gpolo
Date 2008-10-28.17:51:23
SpamBayes Score 1.0283829e-10
Marked as misclassified No
Message-id <1225216284.95.0.159490916659.issue4223@psf.upfronthosting.co.za>
In-reply-to
Content
It seems to depend on working directory:

exarkun@charm:/tmp$ python
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) 
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.append('/home/exarkun/foobar.zip')
>>> import foobar, inspect
>>> inspect.getsource(foobar.foo)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/inspect.py", line 629, in getsource
    lines, lnum = getsourcelines(object)
  File "/usr/lib/python2.5/inspect.py", line 618, in getsourcelines
    lines, lnum = findsource(object)
  File "/usr/lib/python2.5/inspect.py", line 468, in findsource
    raise IOError('could not get source code')
IOError: could not get source code
>>> 

versus:

exarkun@charm:~$ python
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) 
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.append('/home/exarkun/foobar.zip')
>>> import foobar, inspect
>>> inspect.getsource(foobar.foo)
'def foo():\n    pass\n'
>>>
History
Date User Action Args
2008-10-28 17:51:24exarkunsetrecipients: + exarkun, gpolo
2008-10-28 17:51:24exarkunsetmessageid: <1225216284.95.0.159490916659.issue4223@psf.upfronthosting.co.za>
2008-10-28 17:51:24exarkunlinkissue4223 messages
2008-10-28 17:51:23exarkuncreate