mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
[3.14] gh-134280: Disable constant folding for ~ with a boolean argument (GH-134982) (GH-136185)
Some checks are pending
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Lint / lint (push) Waiting to run
Some checks are pending
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Lint / lint (push) Waiting to run
This moves the deprecation warning from compile time to run time.
(cherry picked from commit 86c3316183
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
3bc42942af
commit
8ba024ddf5
3 changed files with 7 additions and 0 deletions
|
@ -292,6 +292,7 @@ class TestTranforms(BytecodeTestCase):
|
|||
('---x', 'UNARY_NEGATIVE', None, False, None, None),
|
||||
('~~~x', 'UNARY_INVERT', None, False, None, None),
|
||||
('+++x', 'CALL_INTRINSIC_1', intrinsic_positive, False, None, None),
|
||||
('~True', 'UNARY_INVERT', None, False, None, None),
|
||||
]
|
||||
|
||||
for (
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Disable constant folding for ``~`` with a boolean argument.
|
||||
This moves the deprecation warning from compile time to runtime.
|
|
@ -1884,6 +1884,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: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue