gh-130851: Don't crash when deduping unusual code constants (#130853) · python/cpython@2905690 · GitHub
Skip to content

Commit 2905690

Browse files
authored
gh-130851: Don't crash when deduping unusual code constants (#130853)
The bytecode compiler only generates a few different types of constants, like str, int, tuple, slices, etc. Users can construct code objects with various unusual constants, including ones that are not hashable or not even constant. The free threaded build previously crashed with a fatal error when confronted with these constants. Instead, treat distinct objects of otherwise unhandled types as not equal for the purposes of deduplication.
1 parent 78d50e9 commit 2905690

3 files changed

Lines changed: 32 additions & 6 deletions

File tree

‎Lib/test/test_code.py‎

Lines changed: 17 additions & 0 deletions
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix a crash in the :term:`free threading` build when constructing a
2+
:class:`code` object with :attr:`~codeobject.co_consts` that contains instances
3+
of types that are not otherwise generated by the bytecode compiler.

‎Objects/codeobject.c‎

Lines changed: 12 additions & 6 deletions

0 commit comments

Comments
 (0)