#17526: fix an IndexError raised while passing code without filename to inspect.findsource(). Initial patch by Tyler Doyle.

This commit is contained in:
Ezio Melotti 2013-03-30 05:10:28 +02:00
parent f03aab7e51
commit e66e7de5d6
3 changed files with 10 additions and 1 deletions

View file

@ -525,7 +525,7 @@ def findsource(object):
file = getfile(object)
sourcefile = getsourcefile(object)
if not sourcefile and file[0] + file[-1] != '<>':
if not sourcefile and file[:1] + file[-1:] != '<>':
raise IOError('source code not available')
file = sourcefile if sourcefile else file