[issue21217] inspect.getsourcelines finds wrong lines when lambda used argument to decorator

2015-07-23 Thread Roundup Robot
Roundup Robot added the comment: New changeset 5400e21e92a7 by Meador Inge in branch '3.5': Issue #24485: Function source inspection fails on closures. https://hg.python.org/cpython/rev/5400e21e92a7 New changeset 0e7d64595223 by Meador Inge in branch 'default': Issue #24485: Function source

[issue21217] inspect.getsourcelines finds wrong lines when lambda used argument to decorator

2015-07-23 Thread Roundup Robot
Roundup Robot added the comment: New changeset 4e42a62d5648 by Yury Selivanov in branch '3.5': Issue #24485: Revert backwards compatibility breaking changes of #21217. https://hg.python.org/cpython/rev/4e42a62d5648 New changeset 98a2bbf2cce2 by Yury Selivanov in branch 'default': Merge 3.5

[issue21217] inspect.getsourcelines finds wrong lines when lambda used argument to decorator

2015-06-28 Thread Meador Inge
Meador Inge added the comment: FYI, I posted a patch to handle this case and the regression noted in issue24485 on issue24485. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21217 ___

[issue21217] inspect.getsourcelines finds wrong lines when lambda used argument to decorator

2015-06-26 Thread Terry J. Reedy
Terry J. Reedy added the comment: I strongly suspect that ac86e5b2d45b is the cause of the regression reported in #24485. def outer(): def inner(): inner1 from inspect import getsource print(getsource(outer)) omits the body of inner. Ditto if outer is a method. All is okay if

[issue21217] inspect.getsourcelines finds wrong lines when lambda used argument to decorator

2015-06-26 Thread Meador Inge
Meador Inge added the comment: I think that the only way we can solve this is to revert the patch for this issue. I agree with this. It seems like doing this analysis at the bytecode level is the wrong approach. Perhaps the syntactical analysis being used before should be beefed up to

[issue21217] inspect.getsourcelines finds wrong lines when lambda used argument to decorator

2015-06-26 Thread Yury Selivanov
Yury Selivanov added the comment: Here's an update on #24485 regression. Looks like getsource() is now using code objects instead of tokenizer to determine blocks first/last lines. The problem with this particular case is that inner function's code object is completely independent from

[issue21217] inspect.getsourcelines finds wrong lines when lambda used argument to decorator

2015-04-14 Thread Thomas Ballinger
Thomas Ballinger added the comment: Thanks Antoine! Could you add Allison Kaptur to NEWS and ACKS? This was an update to her original patch, and we paired on the whole thing. -- ___ Python tracker rep...@bugs.python.org

[issue21217] inspect.getsourcelines finds wrong lines when lambda used argument to decorator

2015-04-14 Thread Roundup Robot
Roundup Robot added the comment: New changeset 582e8e71f635 by Benjamin Peterson in branch 'default': add Allison Kaptur (#21217) https://hg.python.org/cpython/rev/582e8e71f635 -- ___ Python tracker rep...@bugs.python.org

[issue21217] inspect.getsourcelines finds wrong lines when lambda used argument to decorator

2015-04-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: I've committed the latest patch. Thank you, Thomas! -- resolution: - fixed stage: patch review - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21217

[issue21217] inspect.getsourcelines finds wrong lines when lambda used argument to decorator

2015-04-14 Thread Roundup Robot
Roundup Robot added the comment: New changeset ac86e5b2d45b by Antoine Pitrou in branch 'default': Issue #21217: inspect.getsourcelines() now tries to compute the start and https://hg.python.org/cpython/rev/ac86e5b2d45b -- nosy: +python-dev ___

[issue21217] inspect.getsourcelines finds wrong lines when lambda used argument to decorator

2015-04-13 Thread Thomas Ballinger
Thomas Ballinger added the comment: Use dis.findlinestarts() to find lines of function instead of grubbing with co_lnotab manually, making dis module dependency non-optional. -- Added file: http://bugs.python.org/file38970/issue21217-v6.patch ___

[issue21217] inspect.getsourcelines finds wrong lines when lambda used argument to decorator

2015-04-13 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21217 ___ ___ Python-bugs-list mailing

[issue21217] inspect.getsourcelines finds wrong lines when lambda used argument to decorator

2015-04-13 Thread Thomas Ballinger
Thomas Ballinger added the comment: v4 of patch, with tests updated for changed lines in inspect fodder file -- Added file: http://bugs.python.org/file38959/issue21217-v4.patch ___ Python tracker rep...@bugs.python.org

[issue21217] inspect.getsourcelines finds wrong lines when lambda used argument to decorator

2015-04-13 Thread Nick Coghlan
Nick Coghlan added the comment: It sounds like at least a somewhat functional dis module is a pragmatic requirement for a Python implementation to support introspection, so +1 for reverting to the mandatory dependency on dis rather than duplicating its logic. -- nosy: +ncoghlan

[issue21217] inspect.getsourcelines finds wrong lines when lambda used argument to decorator

2015-04-13 Thread Thomas Ballinger
Thomas Ballinger added the comment: Patch reformatted to be non-git style, NEWS item removed -- Added file: http://bugs.python.org/file38965/issue21217-v5.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21217

[issue21217] inspect.getsourcelines finds wrong lines when lambda used argument to decorator

2014-04-15 Thread A Kaptur
A Kaptur added the comment: v2 of the patch incorporating the comments at http://bugs.python.org/review/21217/ -- Added file: http://bugs.python.org/file34882/issue21217-v2.patch ___ Python tracker rep...@bugs.python.org

[issue21217] inspect.getsourcelines finds wrong lines when lambda used argument to decorator

2014-04-15 Thread Yury Selivanov
Yury Selivanov added the comment: Apart from one nit, the patch is looking good. Also, could you please sign the contributor agreement, as described here: https://docs.python.org/devguide/coredev.html#sign-a-contributor-agreement -- ___ Python

[issue21217] inspect.getsourcelines finds wrong lines when lambda used argument to decorator

2014-04-15 Thread Claudiu.Popa
Claudiu.Popa added the comment: - 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? There is an open issue for this,

[issue21217] inspect.getsourcelines finds wrong lines when lambda used argument to decorator

2014-04-15 Thread Yury Selivanov
Yury Selivanov added the comment: Claudiu: I'll take a look at your patch, thanks! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21217 ___ ___

[issue21217] inspect.getsourcelines finds wrong lines when lambda used argument to decorator

2014-04-15 Thread A Kaptur
A Kaptur added the comment: v3 of patch, including misc/news update, docstring for function, and removing class decorator tests, since it sounds like those are better handled in http://bugs.python.org/issue1764286. -- Added file: http://bugs.python.org/file34885/issue21217-v3.patch

[issue21217] inspect.getsourcelines finds wrong lines when lambda used argument to decorator

2014-04-14 Thread Thomas Ballinger
New submission from Thomas Ballinger: https://gist.github.com/thomasballinger/10666031 inspect.getsourcelines incorrectly guesses what lines correspond to the function foo see getblock in inspect.py once it finds a lambda, def or class it finishes it then stops so get getsourcelines returns

[issue21217] inspect.getsourcelines finds wrong lines when lambda used argument to decorator

2014-04-14 Thread Thomas Ballinger
Thomas Ballinger added the comment: The code object's co_lnotab is how inspect should be getting the sourcelines of the code, instead of looking for the first codeblock. I'm looking at this now, thanks to Yhg1s for the above. -- ___ Python tracker

[issue21217] inspect.getsourcelines finds wrong lines when lambda used argument to decorator

2014-04-14 Thread Yury Selivanov
Changes by Yury Selivanov yselivanov...@gmail.com: -- nosy: +yselivanov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21217 ___ ___

[issue21217] inspect.getsourcelines finds wrong lines when lambda used argument to decorator

2014-04-14 Thread A Kaptur
A Kaptur added the comment: 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