Skip to content

Commit

Permalink
Merge pull request #423 from ncaklovic/master
Browse files Browse the repository at this point in the history
COMPARE_OP operand changes in 3.12
  • Loading branch information
zrax authored Jan 4, 2024
2 parents 7560149 + 830dd13 commit 2da061f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
5 changes: 4 additions & 1 deletion ASTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 9 additions & 4 deletions bytecode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2da061f

Please sign in to comment.