Skip to content

Commit 8b3b247

Browse files
committed
Part of xdis API change...
Correct changes from last commit. Make it more explicit that opc is the default opcode for this current Python interpreter
1 parent 79dd5a5 commit 8b3b247

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

trepan/lib/disassemble.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def dis(
116116
if lasti == -1:
117117
lasti = 0
118118
pass
119-
opc = get_opcode(PYTHON_VERSION_TRIPLE, PYTHON_IMPLEMENTATION)
119+
opc = PYTHON_OPCODES
120120
x = x.f_code
121121
if include_header:
122122
header_lines = Bytecode(x, opc).info().split("\n")
@@ -179,7 +179,7 @@ def dis(
179179
return None, None
180180

181181
# Default opc whene none is given.
182-
DEFAULT_OPC = get_opcode(PYTHON_VERSION_TRIPLE, PYTHON_IMPLEMENTATION)
182+
PYTHON_OPCODES = get_opcode(PYTHON_VERSION_TRIPLE, PYTHON_IMPLEMENTATION)
183183

184184
def disassemble(
185185
msg: Callable,
@@ -193,7 +193,7 @@ def disassemble(
193193
start_offset=0,
194194
end_offset=None,
195195
asm_format="extended",
196-
opc=DEFAULT_OPC,
196+
opc=PYTHON_OPCODES,
197197
):
198198
"""Disassemble a code object."""
199199
return disassemble_bytes(
@@ -232,7 +232,7 @@ def print_instruction(
232232
lasti: int=-1,
233233
line_starts = {},
234234
style="none",
235-
opc=DEFAULT_OPC,
235+
opc=PYTHON_OPCODES,
236236
asm_format="extended",
237237
):
238238
"""Disassemble bytecode at offset `offsets`."""
@@ -377,7 +377,7 @@ def disassemble_bytes(
377377
style="none",
378378
start_offset=0,
379379
end_offset=None,
380-
opc=DEFAULT_OPC,
380+
opc=PYTHON_OPCODES,
381381
asm_format="extended",
382382
) -> tuple:
383383
"""Disassemble byte string of code. If end_line is negative
@@ -472,7 +472,7 @@ def disassemble_instruction(
472472
freevars=(),
473473
line_starts={},
474474
style="none",
475-
opc=DEFAULT_OPC,
475+
opc=PYTHON_OPCODES,
476476
asm_format="extended",
477477
) -> tuple:
478478
"""Disassemble byte string of code. If end_line is negative

trepan/processor/command/info_subcmd/frame.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (C) 2015, 2023-2024 Rocky Bernstein <[email protected]>
2+
# Copyright (C) 2015, 2023-2025 Rocky Bernstein <[email protected]>
33
#
44
# This program is free software: you can redistribute it and/or modify
55
# it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@
1919
from pyficache import getline, highlight_string
2020

2121
from trepan.lib.complete import complete_token
22-
from trepan.lib.disassemble import opc
22+
from trepan.lib.disassemble import PYTHON_OPCODES as python_opcodes
2323
from trepan.lib.format import Function, Keyword, format_token
2424
from trepan.lib.stack import format_function_name
2525
from trepan.lib.thred import current_thread_name
@@ -152,7 +152,7 @@ def run(self, args):
152152

153153
f_lasti = frame.f_lasti
154154
if f_lasti >= 0:
155-
opname = opc.opname[code.co_code[f_lasti]]
155+
opname = python_opcodes.opname[code.co_code[f_lasti]]
156156
opname_formatted = format_token(Keyword, opname, style=style)
157157
self.msg(f" instruction offset and opname: {frame.f_lasti} {opname_formatted}")
158158
else:
@@ -164,7 +164,7 @@ def run(self, args):
164164
else:
165165
self.msg(" no previous frame")
166166
self.msg(f" tracing function: {frame.f_trace}")
167-
if hasattr(frame, "f_trace_opcodes"):
167+
if hasattr(frame, "f_trace_python_opcodesodes"):
168168
self.msg_nocr(
169169
f" tracing opcodes: {highlight_string(str(frame.f_trace_opcodes), style=style)}"
170170
)

0 commit comments

Comments
 (0)