diff options
author | Brandt Bucher <brandtbucher@microsoft.com> | 2023-06-29 20:49:54 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-29 20:49:54 (GMT) |
commit | 7b2d94d87513967b357c658c6e7e1b8c8d02487d (patch) | |
tree | bdd79e2c20b235f3d4c1272c8c8e2f1880bfb129 /Doc/library/dis.rst | |
parent | 6e9f83d9aee34192de5d0ef7285be23514911ccd (diff) | |
download | cpython-7b2d94d87513967b357c658c6e7e1b8c8d02487d.zip cpython-7b2d94d87513967b357c658c6e7e1b8c8d02487d.tar.gz cpython-7b2d94d87513967b357c658c6e7e1b8c8d02487d.tar.bz2 |
GH-106008: Make implicit boolean conversions explicit (GH-106003)
Diffstat (limited to 'Doc/library/dis.rst')
-rw-r--r-- | Doc/library/dis.rst | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 63336bb..099b641 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -529,6 +529,9 @@ result back on the stack. Implements ``STACK[-1] = not STACK[-1]``. + .. versionchanged:: 3.13 + This instruction now requires an exact :class:`bool` operand. + .. opcode:: UNARY_INVERT @@ -548,6 +551,13 @@ result back on the stack. .. versionadded:: 3.5 +.. opcode:: TO_BOOL + + Implements ``STACK[-1] = bool(STACK[-1])``. + + .. versionadded:: 3.13 + + **Binary and in-place operations** Binary operations remove the top two items from the stack (``STACK[-1]`` and @@ -1127,7 +1137,12 @@ iterations of the loop. .. opcode:: COMPARE_OP (opname) Performs a Boolean operation. The operation name can be found in - ``cmp_op[opname]``. + ``cmp_op[opname >> 5]``. If the fifth-lowest bit of ``opname`` is set + (``opname & 16``), the result should be coerced to ``bool``. + + .. versionchanged:: 3.13 + The fifth-lowest bit of the oparg now indicates a forced conversion to + :class:`bool`. .. opcode:: IS_OP (invert) @@ -1191,6 +1206,9 @@ iterations of the loop. .. versionchanged:: 3.12 This is no longer a pseudo-instruction. + .. versionchanged:: 3.13 + This instruction now requires an exact :class:`bool` operand. + .. opcode:: POP_JUMP_IF_FALSE (delta) If ``STACK[-1]`` is false, increments the bytecode counter by *delta*. @@ -1204,6 +1222,9 @@ iterations of the loop. .. versionchanged:: 3.12 This is no longer a pseudo-instruction. + .. versionchanged:: 3.13 + This instruction now requires an exact :class:`bool` operand. + .. opcode:: POP_JUMP_IF_NOT_NONE (delta) If ``STACK[-1]`` is not ``None``, increments the bytecode counter by *delta*. |