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

fix: handle small try blocks #145

Merged

Conversation

P403n1x87
Copy link
Contributor

We make sure that we can handle small (and potentially empty) try blocks. These are blocks where the end offset is smaller or at most equal to the start offset. These blocks can occur when a single instruction that requires EXTENDED_ARG opcodes is wrapped in a try block. Original code objects seem to wrap the whole instruction, including the EXTENDED_ARG opcodes. The fix in this PR wraps just the instruction, leaving the extra EXTENDED_ARG opcodes outside the try block. This might not be a problem in general, but it is perhaps not ideal.

Addresses #144.

@codecov-commenter
Copy link

codecov-commenter commented May 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.63%. Comparing base (f1755e8) to head (2992e88).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #145      +/-   ##
==========================================
+ Coverage   95.53%   95.63%   +0.10%     
==========================================
  Files           6        6              
  Lines        1970     1971       +1     
  Branches      474      475       +1     
==========================================
+ Hits         1882     1885       +3     
+ Misses         53       52       -1     
+ Partials       35       34       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

We make sure that we can handle small (and potentially empty) try
blocks. These are blocks where the end offset is smaller or at most
equal to the start offset. These blocks can occur when a single
instruction that requires EXTENDED_ARG opcodes is wrapped in a try
block. Original code objects seem to wrap the whole instruction,
including the EXTENDED_ARG opcodes. The fix in this PR wraps just
the instruction, leaving the extra EXTENDED_ARG opcodes outside the
try block. This might not be a problem in general, but it is perhaps
not ideal.
@P403n1x87 P403n1x87 force-pushed the fix/small-try-block branch from 3820a5c to 598fdea Compare May 17, 2024 14:40
Copy link
Owner

@MatthieuDartiailh MatthieuDartiailh left a comment

Choose a reason for hiding this comment

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

Could you add a changelog entry and address my small comment and I will merge.

tests/test_bytecode.py Show resolved Hide resolved
@MatthieuDartiailh MatthieuDartiailh merged commit c2d97b6 into MatthieuDartiailh:main May 30, 2024
12 checks passed
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