[issue17526] inspect.findsource raises undocumented error for code objects with empty filename

2013-03-29 Thread Ezio Melotti

Ezio Melotti added the comment:

Fixed, thanks for the report and the patch!

--
assignee:  - ezio.melotti
nosy: +ezio.melotti
resolution:  - fixed
stage: needs patch - committed/rejected
status: open - closed
versions:  -Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17526
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17526] inspect.findsource raises undocumented error for code objects with empty filename

2013-03-29 Thread Roundup Robot

Roundup Robot added the comment:

New changeset bc73223e4c10 by Ezio Melotti in branch '2.7':
#17526: fix an IndexError raised while passing code without filename to 
inspect.findsource().  Initial patch by Tyler Doyle.
http://hg.python.org/cpython/rev/bc73223e4c10

New changeset 39e103c1577e by Ezio Melotti in branch '3.3':
#17526: fix an IndexError raised while passing code without filename to 
inspect.findsource().  Initial patch by Tyler Doyle.
http://hg.python.org/cpython/rev/39e103c1577e

New changeset 8362fbb0ef42 by Ezio Melotti in branch 'default':
#17526: merge with 3.3.
http://hg.python.org/cpython/rev/8362fbb0ef42

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17526
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17526] inspect.findsource raises undocumented error for code objects with empty filename

2013-03-27 Thread Tyler Doyle

Changes by Tyler Doyle kingt...@gmail.com:


Removed file: http://bugs.python.org/file29576/inspect.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17526
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17526] inspect.findsource raises undocumented error for code objects with empty filename

2013-03-27 Thread Tyler Doyle

Changes by Tyler Doyle kingt...@gmail.com:


Removed file: http://bugs.python.org/file29577/test_inspect.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17526
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17526] inspect.findsource raises undocumented error for code objects with empty filename

2013-03-27 Thread Tyler Doyle

Changes by Tyler Doyle kingt...@gmail.com:


Added file: http://bugs.python.org/file29591/17526_getsource.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17526
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17526] inspect.findsource raises undocumented error for code objects with empty filename

2013-03-25 Thread Tyler Doyle

Tyler Doyle added the comment:

It looks like file is getting set to '' and then indexed on line 553 below, 
hitting the IndexError before we ever get to IOError.

--550---
file = getfile(object)  -- file = ''
sourcefile = getsourcefile(object)
if not sourcefile and file[0] + file[-1] != '': -- ''[0]
raise IOError('source code not available')
file = sourcefile if sourcefile else file
--556---

Confirmed in 3.3

--
nosy: +T8y8

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17526
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17526] inspect.findsource raises undocumented error for code objects with empty filename

2013-03-25 Thread Nils Bruin

Nils Bruin added the comment:

The most straightforward change I can think of is to change the line

if not sourcefile and file[0] + file[-1] != '':

to

if not sourcefile and (not file or file[0] + file[-1] != ''):

That solves the problem in the cases I have observed.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17526
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17526] inspect.findsource raises undocumented error for code objects with empty filename

2013-03-25 Thread Tyler Doyle

Changes by Tyler Doyle kingt...@gmail.com:


--
keywords: +patch
Added file: http://bugs.python.org/file29576/inspect.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17526
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17526] inspect.findsource raises undocumented error for code objects with empty filename

2013-03-25 Thread Tyler Doyle

Tyler Doyle added the comment:

Patch and test to accompany.

--
Added file: http://bugs.python.org/file29577/test_inspect.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17526
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17526] inspect.findsource raises undocumented error for code objects with empty filename

2013-03-24 Thread R. David Murray

R. David Murray added the comment:

It is very likely the code is the same in 3.3 and 3.4, so I'm adding those 
versions without testing :)

--
keywords: +easy
nosy: +r.david.murray
stage:  - needs patch
versions: +Python 3.3, Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17526
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17526] inspect.findsource raises undocumented error for code objects with empty filename

2013-03-22 Thread Nils Bruin

New submission from Nils Bruin:

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

--
components: Library (Lib)
messages: 185025
nosy: Nils.Bruin
priority: normal
severity: normal
status: open
title: inspect.findsource raises undocumented error for code objects with empty 
filename
type: behavior
versions: Python 2.7, Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17526
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com