Describe the bug
Running the bytecode testsuite (code in this PR MatthieuDartiailh/bytecode#166) on Python 3.14b3 with coverage leads to the following error. Note that the tests pass when disabling coverage measurement:
_______________________________________ DumpCodeTests.test_concrete_bytecode ________________________________________
self = <tests.test_misc.DumpCodeTests testMethod=test_concrete_bytecode>
def test_concrete_bytecode(self):
source = """
def func(test):
if test == 1:
return 1
elif test == 2:
return 2
return 3
"""
> code = disassemble(source, function=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests\test_misc.py:528:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests\__init__.py:143: in disassemble
return Bytecode.from_code(code)
^^^^^^^^^^^^^^^^^^^^^^^^
src\bytecode\bytecode.py:281: in from_code
concrete = _bytecode.ConcreteBytecode.from_code(code)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src\bytecode\concrete.py:353: in from_code
for _, size, _ in (i.cache_info or ()) if PY313 else (): # type: ignore
^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <SysMonitor at 0x209418ac440: 6910 data points in 19 files>
code = <code object from_code at 0x000002093F8F0DC0, file "C:\Users\DartiailhMatthieu\Documents\Coding\Projects\bytecode\src\bytecode\concrete.py", line 332>
instruction_offset = 398, destination_offset = 408
@panopticon("code", "@", "@")
def sysmon_branch_either(
self, code: CodeType, instruction_offset: TOffset, destination_offset: TOffset
) -> MonitorReturn:
"""Handle BRANCH_RIGHT and BRANCH_LEFT events."""
if self.stats is not None:
self.stats["branches"] += 1
code_info = self.code_infos[id(code)]
# code_info is not None and code_info.file_data is not None, since we
# wouldn't have enabled this event if they were.
if not code_info.branch_trails:
if self.stats is not None:
self.stats["branch_trails"] += 1
code_info.branch_trails = branch_trails(code)
# log(f"branch_trails for {code}:\n {code_info.branch_trails}")
added_arc = False
dest_info = code_info.branch_trails.get(instruction_offset)
# log(f"{dest_info = }")
if dest_info is not None:
for offsets, arc in dest_info:
if arc is None:
continue
if destination_offset in offsets:
code_info.file_data.add(arc) # type: ignore
# log(f"adding {arc=}")
added_arc = True
break
if not added_arc:
# This could be an exception jumping from line to line.
assert code_info.byte_to_line is not None
l1 = code_info.byte_to_line[instruction_offset]
> l2 = code_info.byte_to_line[destination_offset]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E KeyError: 408
.venv\Lib\site-packages\coverage\sysmon.py:451: KeyError
To Reproduce
How can we reproduce the problem? Please be specific. Don't link to a failing CI job. Answer the questions below:
Expected behavior
No exception should be raised.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4