This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author orlnub123
Recipients orlnub123
Date 2018-10-29.04:17:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1540786670.85.0.788709270274.issue35101@psf.upfronthosting.co.za>
In-reply-to
Content
If you pass a frame object belonging to a class into findsource, it'll incorrectly give you the starting line number of the first function above it or 0 if no functions are defined.

Here's some code to reproduce the issue:

import inspect

def test_func():
    ...  # This should not get printed

class Test:
    frame = inspect.currentframe()

print(inspect.getsource(Test.frame))  # Depends on findsource

This unexpectedly prints the source of test_func instead of the class right below it.
History
Date User Action Args
2018-10-29 04:17:50orlnub123setrecipients: + orlnub123
2018-10-29 04:17:50orlnub123setmessageid: <1540786670.85.0.788709270274.issue35101@psf.upfronthosting.co.za>
2018-10-29 04:17:50orlnub123linkissue35101 messages
2018-10-29 04:17:50orlnub123create