[issue24485] Function source inspection fails on closures
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 inspection fails on closures. https://hg.python.org/cpython/rev/0e7d64595223 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24485 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24485] Function source inspection fails on closures
Meador Inge added the comment: Thanks Yury! I have committed my patches to 3.5 and default. -- resolution: - fixed stage: patch review - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24485 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24485] Function source inspection fails on closures
Yury Selivanov added the comment: Meador, I've reverted changes introduced in #21217 -- I don't want to risk shipping 3.5beta4 with broken backwards compatibility. Feel free to rebase commit your patch (I decorated test_decorator_with_lambda with @unittest.expectedFailure). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24485 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24485] Function source inspection fails on closures
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 (issues #21217, #24485). https://hg.python.org/cpython/rev/98a2bbf2cce2 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24485 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24485] Function source inspection fails on closures
Yury Selivanov added the comment: Meador, the patch looks OK. Could you please commit it yourself? -- assignee: - meador.inge ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24485 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24485] Function source inspection fails on closures
Meador Inge added the comment: Will do. Thanks for the review. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24485 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24485] Function source inspection fails on closures
Changes by Larry Hastings la...@hastings.org: -- priority: release blocker - normal ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24485 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24485] Function source inspection fails on closures
Meador Inge added the comment: Here is a first cut patch that moves things back to using a syntax-level analysis instead of a bytecode-level one. I extended `BlockFinder` to skip decorators. -- keywords: +patch nosy: +meador.inge stage: test needed - patch review Added file: http://bugs.python.org/file39825/issue24485-v0.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24485 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24485] Function source inspection fails on closures
Terry J. Reedy added the comment: The test suite must lack, and therefore needs, a simple testcase as in test.py. In 3.4 and 3.5, getsource() joins the list of lines returned by getsourcelines(). In both versions, getsourcelines uses findsource(), which seems to be unchanged. In 3.5, the output of findsource for code, function, and method objects is postprocessed by _line_number_helper(code_object). The bug applies to methods also. class C: def outer(): def inner(): inner1 from inspect import getsource print(getsource(C.outer)) omits 'inner1', but getsource(C) does not. I believe the regression is due to ac86e5b2d45b in #21217. (At first glance, it would seem that the fixup in _line_number_helper should be in the code object part of findsource itself.) I requested on that issue that the authors take a look at this. -- stage: needs patch - test needed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24485 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24485] Function source inspection fails on closures
Terry J. Reedy added the comment: I verified (Win7, but should be irrelevant) that test.py works on 2.7.10 and 3.4.3. The failure in 3.5.0b2 is omitting the body of inner. Add another line to inner and both are omitted, so 'body' seems correct Add another line to outer, and nothing is omitted. def outer(): def inner(): inner1 inner2 outer2 is displayed completely. So the omission is the body of an inner function that is the last statement of outer. This rule is not recursive, in the sense that for def outer(): def middle(): def inner(): inner1 def inner ... is entirely omitted, not just 'inner1'. The omission seems specific to 'def' as it does not occur with the other compound statements I tested (if, while). -- nosy: +terry.reedy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24485 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24485] Function source inspection fails on closures
Yury Selivanov added the comment: Thanks, Terry. I posted some findings to #21217. -- nosy: +ncoghlan, pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24485 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24485] Function source inspection fails on closures
Yury Selivanov added the comment: Looks like this is a regression in 3.5. -- priority: normal - release blocker stage: - needs patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24485 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24485] Function source inspection fails on closures
Changes by Yury Selivanov yseliva...@gmail.com: -- nosy: +yselivanov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24485 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24485] Function source inspection fails on closures
New submission from Malthe Borch: Very simple to reproduce (see attachment). -- components: Library (Lib) files: test.py messages: 245621 nosy: malthe priority: normal severity: normal status: open title: Function source inspection fails on closures type: behavior versions: Python 3.5, Python 3.6 Added file: http://bugs.python.org/file39768/test.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24485 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24485] Function source inspection fails on closures
Changes by bkcsfi sfi bkc...@gmail.com: -- nosy: +bkcsfi sfi ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24485 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com