From: Benjamin Peterson Date: Sun, 20 Jul 2014 20:04:11 +0000 (-0700) Subject: correct ref counting of default_action (closes #22017) X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0fb88f7c51cca016e6210e8058b5d5d271f79989;p=python correct ref counting of default_action (closes #22017) --- diff --git a/Misc/NEWS b/Misc/NEWS index d2fc3e2938..efad9ea241 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -13,6 +13,9 @@ Core and Builtins Library ------- +- Issue #22017: Correct reference counting errror in the initialization of the + _warnings module. + - Issue 21044: tarfile.open() now handles fileobj with an integer 'name' attribute. Based on patch by Martin Panter. diff --git a/Python/_warnings.c b/Python/_warnings.c index 445ff6ba9e..92d6547a7c 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -905,6 +905,7 @@ _PyWarnings_Init(void) _default_action = PyString_FromString("default"); if (_default_action == NULL) return; + Py_INCREF(_default_action); if (PyModule_AddObject(m, "default_action", _default_action) < 0) return; }