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

Reply via email to