From 916103179ce4c03c7cef27b03962f7951d582c76 Mon Sep 17 00:00:00 2001 From: Roman Avdeenko Date: Sat, 19 Aug 2023 17:43:04 +0300 Subject: [PATCH] Fix LOAD_GLOBAL_A operand printing for versions prior to 3.11 --- bytecode.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bytecode.cpp b/bytecode.cpp index cad4ab0..99280a5 100644 --- a/bytecode.cpp +++ b/bytecode.cpp @@ -395,10 +395,14 @@ void bc_disasm(std::ostream& pyc_output, PycRef 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 ", operand); }