]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-130851: Only intern constants of types generated by the compiler (#130901)
authorSam Gross <colesbury@gmail.com>
Fri, 7 Mar 2025 15:34:53 +0000 (10:34 -0500)
committerGitHub <noreply@github.com>
Fri, 7 Mar 2025 15:34:53 +0000 (10:34 -0500)
commit12db45211d411583cbe272c7ba6811a811b721ca
tree9533799ca044e94354da6ff226120711ab81ca49
parentc476410dc5ae62ffb5e32f64f9a3a622485c7d93
gh-130851: Only intern constants of types generated by the compiler (#130901)

The free-threading build interns and immortalizes most constants
generated by the bytecode compiler. However, users can construct their
own code objects with arbitrary constants. We should not intern or
immortalize these objects if they are not of a type that we know how to
handle.

This change fixes a reference leak failure in the recently added
`test_code.test_unusual_constants` test. It also addresses a potential
crash that could occur when attempting to destroy an immortalized
object during interpreter shutdown.
Objects/codeobject.c