Message185025
It would seem reasonable that an empty filename would be a legitimate way of indicating that a code object does not have a corresponding source file. However, if one does that then inspect.findsource raises an unexpected IndexError rather than the documented IOError.
This seems due to the fix introduced on issue9284
Python 3.2.3 (default, Jun 8 2012, 05:40:07)
[GCC 4.6.3 20120306 (Red Hat 4.6.3-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import inspect
>>> C=compile("print(1)","<string>","single")
>>> D=compile("print(1)","","single")
>>> inspect.findsource(C)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.2/inspect.py", line 547, in findsource
raise IOError('could not get source code')
IOError: could not get source code
>>> inspect.findsource(D)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.2/inspect.py", line 537, in findsource
if not sourcefile and file[0] + file[-1] != '<>':
IndexError: string index out of range |
|
Date |
User |
Action |
Args |
2013-03-23 02:03:59 | Nils.Bruin | set | recipients:
+ Nils.Bruin |
2013-03-23 02:03:59 | Nils.Bruin | set | messageid: <1364004239.34.0.135236485776.issue17526@psf.upfronthosting.co.za> |
2013-03-23 02:03:59 | Nils.Bruin | link | issue17526 messages |
2013-03-23 02:03:58 | Nils.Bruin | create | |
|