diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2025-07-01 20:24:04 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-01 20:24:04 +0300 |
commit | 86c3316183a79867e3c666d0830f897e16f0f339 (patch) | |
tree | 1d219457f6013fc030011f412ebd7b8aa64402f9 /Python/flowgraph.c | |
parent | e0d6500b2d9a08beb7b607b846d1eeaa26706667 (diff) | |
download | cpython-86c3316183a79867e3c666d0830f897e16f0f339.tar.gz cpython-86c3316183a79867e3c666d0830f897e16f0f339.zip |
gh-134280: Disable constant folding for ~ with a boolean argument (GH-134982)
This moves the deprecation warning from compile time to run time.
Diffstat (limited to 'Python/flowgraph.c')
-rw-r--r-- | Python/flowgraph.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Python/flowgraph.c b/Python/flowgraph.c index 2adc8c84d83..1cb6f03169e 100644 --- a/Python/flowgraph.c +++ b/Python/flowgraph.c @@ -1892,6 +1892,10 @@ eval_const_unaryop(PyObject *operand, int opcode, int oparg) result = PyNumber_Negative(operand); break; case UNARY_INVERT: + // XXX: This should be removed once the ~bool depreciation expires. + if (PyBool_Check(operand)) { + return NULL; + } result = PyNumber_Invert(operand); break; case UNARY_NOT: { |