Skip to content

Commit

Permalink
Fix LOAD_GLOBAL_A operand printing for versions prior to 3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Avdeenko committed Aug 19, 2023
1 parent bb54b27 commit 9161031
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions bytecode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,14 @@ void bc_disasm(std::ostream& pyc_output, PycRef<PycCode> code, PycModule* mod,
} else if (opcode == Pyc::LOAD_GLOBAL_A) {
// Special case for Python 3.11+
try {
if (operand & 1)
formatted_print(pyc_output, "%d: NULL + %s", operand, code->getName(operand >> 1)->value());
// Explicitly check for 3.11+
if (mod->verCompare(3, 11) >= 0)
if (operand & 1)
formatted_print(pyc_output, "%d: NULL + %s", operand, code->getName(operand >> 1)->value());
else
formatted_print(pyc_output, "%d: %s", operand, code->getName(operand >> 1)->value());
else
formatted_print(pyc_output, "%d: %s", operand, code->getName(operand >> 1)->value());
formatted_print(pyc_output, "%d: %s", operand, code->getName(operand)->value());
} catch (const std::out_of_range &) {
formatted_print(pyc_output, "%d <INVALID>", operand);
}
Expand Down

0 comments on commit 9161031

Please sign in to comment.