@@ -529,6 +529,9 @@ result back on the stack.
529529
530530 Implements ``STACK[-1] = not STACK[-1] ``.
531531
532+ .. versionchanged :: 3.13
533+ This instruction now requires an exact :class: `bool ` operand.
534+
532535
533536.. opcode :: UNARY_INVERT
534537
@@ -548,6 +551,13 @@ result back on the stack.
548551 .. versionadded :: 3.5
549552
550553
554+ .. opcode :: TO_BOOL
555+
556+ Implements ``STACK[-1] = bool(STACK[-1]) ``.
557+
558+ .. versionadded :: 3.13
559+
560+
551561**Binary and in-place operations **
552562
553563Binary operations remove the top two items from the stack (``STACK[-1] `` and
@@ -1127,7 +1137,12 @@ iterations of the loop.
11271137.. opcode :: COMPARE_OP (opname)
11281138
11291139 Performs a Boolean operation. The operation name can be found in
1130- ``cmp_op[opname] ``.
1140+ ``cmp_op[opname >> 5] ``. If the fifth-lowest bit of ``opname `` is set
1141+ (``opname & 16 ``), the result should be coerced to ``bool ``.
1142+
1143+ .. versionchanged :: 3.13
1144+ The fifth-lowest bit of the oparg now indicates a forced conversion to
1145+ :class: `bool `.
11311146
11321147
11331148.. opcode :: IS_OP (invert)
@@ -1191,6 +1206,9 @@ iterations of the loop.
11911206 .. versionchanged :: 3.12
11921207 This is no longer a pseudo-instruction.
11931208
1209+ .. versionchanged :: 3.13
1210+ This instruction now requires an exact :class: `bool ` operand.
1211+
11941212.. opcode :: POP_JUMP_IF_FALSE (delta)
11951213
11961214 If ``STACK[-1] `` is false, increments the bytecode counter by *delta *.
@@ -1204,6 +1222,9 @@ iterations of the loop.
12041222 .. versionchanged :: 3.12
12051223 This is no longer a pseudo-instruction.
12061224
1225+ .. versionchanged :: 3.13
1226+ This instruction now requires an exact :class: `bool ` operand.
1227+
12071228.. opcode :: POP_JUMP_IF_NOT_NONE (delta)
12081229
12091230 If ``STACK[-1] `` is not ``None ``, increments the bytecode counter by *delta *.
0 commit comments