Author akaptur
Recipients akaptur, ballingt, yselivanov
Date 2014-04-14.22:49:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
This patch adds tests demonstrating broken behavior inspect.getsource and inspect.getsourcelines of decorators containing lambda functions, and modifies inspect.getsourcelines to behave correctly.

We use co_lnotab to extract line numbers on all objects with a code object. inspect.getsourcelines can also take a class, which cannot use co_lnotab as there is no associated code object.

@ballingt and I paired on this patch.

Some open questions about inspect.getsource not created or addressed by this patch:
- Is this a bug that should be patched in previous versions as well?
- the docs for say it can take a traceback. What is the correct behavior here?  There aren't any tests at the moment. We suggest the line of code that caused the traceback, i.e. the line at tb.tb_lineno
-  We added tests of decorated classes. The source of decorated classes does not include the decorators, which is different than the usual behavior of decorated functions. What is the correct behavior here?
- inspect.getblock and inspect.BlockFinder use the term "block" in a way that is inconsistent with its typical use in the interpreter (that is, in ceval.c). Should this be renamed? If so, to what? ("chunk"?)
Date User Action Args
2014-04-14 22:49:51akaptursetrecipients: + akaptur, yselivanov, ballingt
2014-04-14 22:49:51akaptursetmessageid: <>
2014-04-14 22:49:51akapturlinkissue21217 messages
2014-04-14 22:49:51akapturcreate