Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Prev Previous commit
Next Next commit
handle case of negative shift
  • Loading branch information
eendebakpt committed Jan 29, 2025
commit 70ad42a3c43f60c82a38b159953b4b56bf0c7e63
1 change: 1 addition & 0 deletions Lib/test/test_opcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,7 @@ def binary_op_bitwise_extend():
self.assert_specialized(binary_op_bitwise_extend, "BINARY_OP_EXTEND")
self.assert_no_opcode(binary_op_bitwise_extend, "BINARY_OP")

# check that after specialization of >> we handle negative shifts
for idx in range(100):
a, b = 2, 1
if idx == 99:
Expand Down
2 changes: 1 addition & 1 deletion Python/specialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -2463,7 +2463,7 @@ compactlongs_guard(PyObject *lhs, PyObject *rhs)
static int
compactlong_compactnonnegativelong_guard(PyObject *lhs, PyObject *rhs)
{
return (is_compactlong(lhs) && is_compactnonnegativelong(rhs);
return (is_compactlong(lhs) && is_compactnonnegativelong(rhs));
}

#define BITWISE_LONGS_ACTION(NAME, OP) \
Expand Down