New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
inspect.getsource() returns incorrect source lines at the module level #50949
Comments
inspect.getsource(obj) returns incorrect results when obj is a This demo script shows the problem. The correct output should contain D:\temp>type show_inspect_bug.py import inspect
frame = inspect.currentframe()
print inspect.getsource(frame) D:\temp>python show_inspect_bug.py The attached patch fixes the problem and adds some missing test cases. |
Confirmed in trunk and py3k. Also affects inspect.getsourcelines. |
I confirmed the issue in tip. One of the issues with the original patch is An alternative approach is to check in getsourcelines whether or not we're |
Thanks for reporting this, Gabriel! Thanks for the PR, Vladimir! |
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: