Crash report
What happened?
In CPython 3.14 and later, assigning to the global __conditional_annotations__ before a variable annotation produces a segfault.
Here is a minimal reproducible example:
__conditional_annotations__ = 0
a: 1
Analyzing the bytecode, the compiler first initializes __conditional_annotations__ to an empty set. Whenever an annotation is declared, a SET_ADD is emitted under the assumption that the underlying type is still a set. But we can re-assign __conditional_annotations__ to another object in between, leading to a type confusion:
BUILD_SET 0
STORE_NAME 0 (__conditional_annotations__)
LOAD_SMALL_INT 0
STORE_NAME 0 (__conditional_annotations__)
LOAD_NAME 0 (__conditional_annotations__)
LOAD_SMALL_INT 0
SET_ADD 1
CPython versions tested on:
3.14, 3.15
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
No response
Crash report
What happened?
In CPython 3.14 and later, assigning to the global
__conditional_annotations__before a variable annotation produces a segfault.Here is a minimal reproducible example:
Analyzing the bytecode, the compiler first initializes
__conditional_annotations__to an empty set. Whenever an annotation is declared, aSET_ADDis emitted under the assumption that the underlying type is still a set. But we can re-assign__conditional_annotations__to another object in between, leading to a type confusion:CPython versions tested on:
3.14, 3.15
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
No response