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
bpo-22352: Adjust widths in the output of dis.dis() for large line… #1153
bpo-22352: Adjust widths in the output of dis.dis() for large line… #1153
Conversation
…mbers and instruction offsets. Add tests for widths of opcode names.
@serhiy-storchaka, thanks for your PR! By analyzing the history of the files in this pull request, we identified @ncoghlan, @benjaminp and @tim-one to be potential reviewers. |
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.
Looks like a nice improvement to me.
One inline comment regarding the opcodes that are already more than 20 letters long, but that's really a question for a separate issue.
def test_widths(self): | ||
for opcode, opname in enumerate(dis.opname): | ||
if opname in ('BUILD_MAP_UNPACK_WITH_CALL', | ||
'BUILD_TUPLE_UNPACK_WITH_CALL'): |
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.
While I don't think it should block this change (since it's an existing problem) I wonder if it might it be worth special-casing these for display purposes using something like:
BUILD_MAP_UNPACK_WITH_CALL
...MAP_UNPACK+CALL
12345678901234567890
BUILD_TUPLE_UNPACK_WITH_CALL
...TUPLE_UNPACK+CALL
12345678901234567890
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.
Sorry, I don't understand your idea. This already is special-cased, the test is skipped for these names.
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.
I meant in the actual display code, as I assume the columns are currently misaligned for rows containing these two opcodes, whereas they wouldn't be given the abbreviations (...TUPLE_UNPACK+CALL
is 20 characters, while ...MAP_UNPACK+CALL
is 18).
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.
I think it is better to misalign columns than output corrupted opcode names.
It may be worth to rename these two opcodes, but this is different issue.
… numbers and
instruction offsets.
Add tests for widths of opcode names.