Skip to content
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

Merged
merged 6 commits into from
Oct 26, 2023

Conversation

pablogsal
Copy link
Member

@pablogsal pablogsal commented Oct 23, 2023

@pablogsal pablogsal changed the title lo gh-67224: Show source lines in tracebacks when using the -c option when running Python Oct 23, 2023
…ion when running Python

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
@@ -5,10 +5,8 @@
that name.
"""

import functools
Copy link
Member Author

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):
Copy link
Member Author

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

@lysnikolaou
Copy link
Member

There's some tests failing still.

@pablogsal pablogsal requested a review from gpshead as a code owner October 24, 2023 08:20
@lysnikolaou
Copy link
Member

There appears to be merge conflicts.

@AlexWaygood
Copy link
Member

AlexWaygood commented Oct 24, 2023

I fixed the merge conflicts, but it looks like some tests are still failing

@pablogsal
Copy link
Member Author

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

@pablogsal
Copy link
Member Author

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 eval() (which would be nice to also cache, but that would affect runtime memory footprint so we probably don't want to do that)

@pablogsal
Copy link
Member Author

@lysnikolaou Please, take another look when you can

Copy link
Member

@lysnikolaou lysnikolaou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, looks good!

@pablogsal pablogsal merged commit 90a1b28 into python:main Oct 26, 2023
@pablogsal pablogsal deleted the lo branch October 26, 2023 06:17
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
brandtbucher added a commit to brandtbucher/cpython that referenced this pull request Mar 27, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants