File tree Expand file tree Collapse file tree 2 files changed +2
-22
lines changed
Misc/NEWS.d/next/Core and Builtins Expand file tree Collapse file tree 2 files changed +2
-22
lines changed Original file line number Diff line number Diff line change @@ -417,8 +417,7 @@ New Features
417417 which has an ambiguous return value.
418418 (Contributed by Irit Katriel and Erlend Aasland in :gh: `105201 `.)
419419
420- * Modified the ``_PyUnicode_ClearInterned `` function to always delete all
421- interned strings during a call to :c:func: `Py_Finalize `. This
420+ * :c:func: `Py_Finalize ` now deletes all interned strings. This
422421 is backwards incompatible to any C-Extension that holds onto an interned
423422 string after a call to :c:func: `Py_Finalize ` and is then reused after a
424423 call to :c:func: `Py_Initialize `. Any issues arising from this behavior will
Original file line number Diff line number Diff line change 1- This updates the interned string deallocation function
2- ``_PyUnicode_ClearInterned `` to delete all interned strings during runtime
3- finalization when calling ``Py_Finalize ``, regardless of their reference
4- count.
5-
6- Worth noting that if an extension accidentally holds onto a interned string,
7- even after calling Py_Finalize, it will result in use-after-free error,
8- leaving the user to a potential vulnerabilities. That said, the history of
9- how these interned strings are handled have been changing during throughout
10- different versions.
11-
12- For example, in Python 3.9 and older, interned strings were never deleted.
13- Only special builds for Valgrind and Purity cleared them at exit. In Python
14- 3.10 and 3.11, interned strings are always deleted at exit. In Python 3.12,
15- interned strings are deleted only if Python is built in debug mode: they
16- are not deleted in release mode. In Python 3.13, interned strings will
17- now be all deleted.
18-
19- Given how the guarantees changed throughout different versions, it is not
20- expected that users actively rely on this behavior for their extensions.
1+ :c:func: `Py_Finalize ` now deletes all interned strings.
You can’t perform that action at this time.
0 commit comments