Skip to content

gh-132413: Clear weakref to _datetime after modules are finalized #136152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 13 commits into from
Prev Previous commit
Next Next commit
Avoid weakref being cleared by GC
  • Loading branch information
neonene authored Jun 30, 2025
commit 4e83b5b3e302b635120d47d09f8119ce6f8b9a2b
12 changes: 11 additions & 1 deletion Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,17 @@ finalize_remove_modules(PyObject *modules, int verbose)
if (weaklist != NULL) { \
PyObject *wr = PyWeakref_NewRef(mod, NULL); \
if (wr) { \
PyObject *tup = PyTuple_Pack(2, name, wr); \
PyObject *tup; \
if (Py_REFCNT(wr) > 1) { \
/* gh-132413: When the weakref is already used
* elsewhere, keep the referenced module alive
* until finalize_modules_clear_weaklist() finishes.
*/ \
tup = PyTuple_Pack(3, name, wr, mod); \
} \
else { \
tup = PyTuple_Pack(2, name, wr); \
} \
if (!tup || PyList_Append(weaklist, tup) < 0) { \
PyErr_FormatUnraisable("Exception ignored while removing modules"); \
} \
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy