MatthieuDartiailh / bytecode

Python module to modify bytecode
https://bytecode.readthedocs.io/
MIT License
302 stars 38 forks source link

fix: handle small try blocks #145

Closed P403n1x87 closed 6 months ago

P403n1x87 commented 6 months ago

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 commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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

Additional details and impacted files ```diff @@ 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 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.