COMPARE_OP operand changes in 3.12

This commit is contained in:
Nenad Čaklović
2024-01-04 23:42:54 +01:00
parent 7560149895
commit 830dd13228
2 changed files with 13 additions and 5 deletions

View File

@@ -638,7 +638,10 @@ PycRef<ASTNode> BuildFromCode(PycRef<PycCode> code, PycModule* mod)
stack.pop();
PycRef<ASTNode> left = stack.top();
stack.pop();
stack.push(new ASTCompare(left, right, operand));
auto arg = operand;
if (mod->verCompare(3, 12) >= 0)
arg >>= 4; // changed under GH-100923
stack.push(new ASTCompare(left, right, arg));
}
break;
case Pyc::CONTAINS_OP_A:

View File

@@ -489,10 +489,15 @@ void bc_disasm(std::ostream& pyc_output, PycRef<PycCode> code, PycModule* mod,
}
break;
case Pyc::COMPARE_OP_A:
if (static_cast<size_t>(operand) < cmp_strings_len)
formatted_print(pyc_output, "%d (%s)", operand, cmp_strings[operand]);
else
formatted_print(pyc_output, "%d (UNKNOWN)", operand);
{
auto arg = operand;
if (mod->verCompare(3, 12) >= 0)
arg >>= 4; // changed under GH-100923
if (static_cast<size_t>(arg) < cmp_strings_len)
formatted_print(pyc_output, "%d (%s)", operand, cmp_strings[arg]);
else
formatted_print(pyc_output, "%d (UNKNOWN)", operand);
}
break;
case Pyc::BINARY_OP_A:
if (static_cast<size_t>(operand) < binop_strings_len)