[New-bugs-announce] [issue15128] inspect raises exception when frames are misleading about source line numbers

Kevin M. Turner report at bugs.python.org
Thu Jun 21 20:01:08 CEST 2012


New submission from Kevin M. Turner <acapnotic at users.sourceforge.net>:

The attached example shows how inspect.findsource fails when given a stack frame that points to a non-existent source line, and how inspect.getframeinfo and getinnerframes do not handle that failure.

On the one hand, yes, this code was asking for it by building such a broken frame.  On the other hand, having code that examines tracebacks result in tracebacks of its own sucks a whole bunch.

The inspect find&get source methods are documented as returning IOError if they cannot find the source, and the calling code handles that case, so that's probably what should happen here.

(Actually, that seems straightforward enough, I can make a patch for that shortly.)

This may help with issue #1628987 as well.

----------
components: Library (Lib)
files: inspectLineNumber.py
messages: 163355
nosy: acapnotic
priority: normal
severity: normal
status: open
title: inspect raises exception when frames are misleading about source line numbers
versions: Python 2.6, Python 2.7
Added file: http://bugs.python.org/file26073/inspectLineNumber.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15128>
_______________________________________


More information about the New-bugs-announce mailing list