Skip to content

bpo-43950: Print columns in tracebacks (PEP 657) #26958

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

Merged
merged 5 commits into from
Jul 4, 2021

Conversation

ammaraskar
Copy link
Member

@ammaraskar ammaraskar commented Jun 29, 2021

This pull request implements the relevant bits in traceback printing to utilize the new co_positions and PyCode_Addr2... APIs to print carets for column locations.

All the internal structures, and data representation are subjected to change in future PRs as we add optimizations.

https://bugs.python.org/issue43950

@ammaraskar ammaraskar force-pushed the codeobject_changes branch 8 times, most recently from d69a6a4 to 6d4302d Compare July 2, 2021 01:44
@ammaraskar ammaraskar changed the title bpo-43950: Make compiler output more source offsets. bpo-43950: Print columns in tracebacks (PEP 657) Jul 2, 2021
@pablogsal
Copy link
Member

@ammaraskar Ground control to major tom, commencing countdown engines on

Rebase time!

@pablogsal
Copy link
Member

@pablogsal would you mind cleaning up the byte_to_character_offset_in_line function here.

Yeah, I will do that. Could you address first @isidentical feedback?

@ammaraskar ammaraskar force-pushed the codeobject_changes branch from 73bcea3 to 9a31711 Compare July 4, 2021 19:59
@pablogsal pablogsal force-pushed the codeobject_changes branch 6 times, most recently from e0b1f4b to 58e2f7f Compare July 4, 2021 22:24
@pablogsal pablogsal merged commit 5644c7b into python:main Jul 4, 2021
@pablogsal pablogsal deleted the codeobject_changes branch July 4, 2021 23:14
@pablogsal
Copy link
Member

@ammaraskar Can you open the prs for the follow-ups?

#26958 (comment)

@ammaraskar
Copy link
Member Author

#27023 for the config change, working on the traceback.py refactor + a bpo issue.

@ammaraskar
Copy link
Member Author

https://bugs.python.org/issue44569 for the traceback.py change, PR for it coming soon.

@@ -309,7 +321,7 @@ def walk_stack(f):
current stack is used. Usually used with StackSummary.extract.
"""
if f is None:
f = sys._getframe().f_back.f_back
f = sys._getframe().f_back.f_back.f_back.f_back
Copy link
Contributor

Choose a reason for hiding this comment

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

this doesn't seem correct -

Python 3.11.0 | packaged by conda-forge | (main, Oct 25 2022, 06:18:27) [GCC 10.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import traceback
>>> traceback.walk_stack(None)
<generator object walk_stack at 0x7f308f4c4700>
>>> list(traceback.walk_stack(None))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/graingert/anaconda3/envs/dask-distributed-311/lib/python3.11/traceback.py", line 332, in walk_stack
    f = sys._getframe().f_back.f_back.f_back.f_back
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'f_back'
>>> 

Copy link
Member

Choose a reason for hiding this comment

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

Please, don't comment on merged pull requests because they are not monitored and you risk no one looking at your comment. Always open a new issue :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants