From 0fb88f7c51cca016e6210e8058b5d5d271f79989 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sun, 20 Jul 2014 13:04:11 -0700 Subject: [PATCH] correct ref counting of default_action (closes #22017) --- Misc/NEWS | 3 +++ Python/_warnings.c | 1 + 2 files changed, 4 insertions(+) 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; } -- 2.50.1