You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
orlnub123mannequin opened this issue
Oct 29, 2018
· 3 comments
Labels
3.11only security fixes3.12bugs and security fixes3.13new features, bugs and security fixesstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error
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:
importinspectdeftest_func():
... # This should not get printedclassTest:
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.
Seems there is a related open issue with a similar regex based solution proposed for another class definition related issue : https://bugs.python.org/issue22355#msg226538 . I think it's worth converting the example code reported in bpo-22355 as unit test cases. Since this issue already has a PR with tests then we can proceed further on this.
3.11only security fixes3.12bugs and security fixes3.13new features, bugs and security fixesstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: