Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-112620: Fix dis error on show_cache with labels #112621

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 1 commit into from
Dec 3, 2023

Conversation

iritkatriel
Copy link
Member

@iritkatriel iritkatriel commented Dec 2, 2023

Cache entries take the label_width from the instruction that precedes them.

The dis module needs to be refactored to separate Instruction generation from formatting, then this will be simpler.

Fixes #112620.

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

Wouldn't it be simpler to add an optional label_width keyword arg to Instruction? Or is that signature unchangeable? The root cause seems to be that Instruction has a label_width attribute that's not set by the constructor but by some code called immediately after the constructor -- but this is done only for regular instructions, not for the ("fake"?) instructions used to render cache entries. (Ditto for exc_handler.)

I understand that for backwards compatibility we can't make these two fields slots in _Instruction -- but we could still set them in Instruction.__init__()? (We'd have to add that method.)

@iritkatriel
Copy link
Member Author

I could do that, but ultimately my plan is to separate instruction generation from formatting, and then the label width is not a property of the instruction.

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

Okay, let's fix it this way for now then.

@iritkatriel iritkatriel merged commit 162d3d4 into python:main Dec 3, 2023
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AttributeError in 'python -m dis -C'
2 participants