diff options
author | Guido van Rossum <guido@python.org> | 2023-08-25 17:04:35 -0700 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2023-08-26 06:33:04 +0200 |
commit | d74a1fcfe3c46e9a665caef5a540de20995e3900 (patch) | |
tree | ddf3bfe371177434d611b85bb54c72b07babb0b8 | |
parent | [3.12] Docs: Datamodel: Merge "Notes on using __slots__" with the parent sect... (diff) | |
download | cpython-d74a1fcfe3c46e9a665caef5a540de20995e3900.tar.gz cpython-d74a1fcfe3c46e9a665caef5a540de20995e3900.tar.bz2 cpython-d74a1fcfe3c46e9a665caef5a540de20995e3900.zip |
Remove assert that should've been DEOPT_IF
The assert(method != NULL) in CALL_NO_KW_LIST_APPEND is wrong --
this condition should lead to a deoptimization, and indeed there
is a DEOPT_IF two lines later that will trigger if method == NULL.
This would crash in a devious repro scenario (first seen live
in boto3 tests) when compiled with assertions enabled.
In a production version there is no crash, so impact is limited.
(The crash also appears in main; I will prepare a separate PR.)
-rw-r--r-- | Python/bytecodes.c | 2 | ||||
-rw-r--r-- | Python/generated_cases.c.h | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c index dc2ae221f0b..d1c79371c45 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -2992,7 +2992,7 @@ dummy_func( inst(CALL_NO_KW_LIST_APPEND, (unused/1, unused/2, method, self, args[oparg] -- unused)) { assert(kwnames == NULL); assert(oparg == 1); - assert(method != NULL); + PyInterpreterState *interp = _PyInterpreterState_GET(); DEOPT_IF(method != interp->callable_cache.list_append, CALL); DEOPT_IF(!PyList_Check(self), CALL); diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index b0a363ce9aa..e697352b8d9 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -4248,7 +4248,7 @@ #line 2993 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); - assert(method != NULL); + PyInterpreterState *interp = _PyInterpreterState_GET(); DEOPT_IF(method != interp->callable_cache.list_append, CALL); DEOPT_IF(!PyList_Check(self), CALL); |