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 "outer"'s. So, for an outer() function below: def outer(): def inner(): never_reached1 never_reached2 the code object contains the following opcodes: 71 0 LOAD_CONST 1 (<code object inner ...>) 3 LOAD_CONST 2 ('outer1.<locals>.inner') 6 MAKE_FUNCTION 0 9 STORE_FAST 0 (inner) 12 LOAD_CONST 0 (None) 15 RETURN_VALUE The correct solution is to use co_lnotab along with co_firstlineno to iterate through opcodes recursively accounting for MAKE_FUNCTION's code objects. *However*, I don't think we can solve this for classes, i.e. def outer_with_class(): class Foo: b = 1 a = 2 there is no way (as far as I know) to get information about the Foo class start/end lineno. I think that the only way we can solve this is to revert the patch for this issue. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue21217> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com