-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
gh-67224: Show source lines in tracebacks when using the -c option when running Python #111200
Conversation
pablogsal
commented
Oct 23, 2023
•
edited by bedevere-app
bot
Loading
edited by bedevere-app
bot
- Issue: python -c: Line causing exception not shown for exceptions other than SyntaxErrors #67224
…ion when running Python Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
@@ -5,10 +5,8 @@ | |||
that name. | |||
""" | |||
|
|||
import functools |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These imports are moved to the functions to avoid problems that arise trying to import these modules too early (they help breaking some circular dependency)
@@ -176,11 +176,13 @@ def lazycache(filename, module_globals): | |||
get_source = getattr(loader, 'get_source', None) | |||
|
|||
if name and get_source: | |||
get_lines = functools.partial(get_source, name) | |||
def get_lines(name=name, *args, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just to drop the functools dependency
There's some tests failing still. |
… -c option when running Python
…ing the -c option when running Python
There appears to be merge conflicts. |
I fixed the merge conflicts, but it looks like some tests are still failing |
The gdb failures look odd so I wonder if they are coming from main. I will take a look at the other failures soon, but this is getting quite tricky because all the test are checking for the name of the source in weird places |
…when using the -c option when running Python
I think I found the problem and I have restructured everything to be less annoying to fix everywhere. The fact that this code path is used for everything makes it a bit more difficult to special-case for things that are not calls to |
@lysnikolaou Please, take another look when you can |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, looks good!
…ion when running Python (python#111200)
…ion when running Python (python#111200)