This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author xdegaye
Recipients xdegaye
Date 2014-07-20.16:24:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1405873474.62.0.40643670319.issue22017@psf.upfronthosting.co.za>
In-reply-to
Content
$ ./python
Python 2.7.8+ (2.7:5563f895b215, Jul 20 2014, 18:10:28) 
[GCC 4.9.0 20140521 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import warnings
>>> warnings.defaultaction = 'default'
>>> warnings.warn('some warning')
__main__:1: UserWarning: some warning
>>> exit()
Fatal Python error: Objects/dictobject.c:519 object at 0x7fce2013e2e0 has negative ref count -2604246222170760230
Aborted (core dumped)

The following patch fixes this: the new string object is referenced both by the static variable '_default_action' and the module attribute 'default_action'.
Python 3.5 handles this correctly.
The same kind of fix should also be applied to '_once_registry' and '_filters'.

diff --git a/Python/_warnings.c b/Python/_warnings.c
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -903,6 +903,7 @@
         return;
 
     _default_action = PyString_FromString("default");
+    Py_INCREF(_default_action);
     if (_default_action == NULL)
         return;
     if (PyModule_AddObject(m, "default_action", _default_action) < 0)
History
Date User Action Args
2014-07-20 16:24:34xdegayesetrecipients: + xdegaye
2014-07-20 16:24:34xdegayesetmessageid: <1405873474.62.0.40643670319.issue22017@psf.upfronthosting.co.za>
2014-07-20 16:24:34xdegayelinkissue22017 messages
2014-07-20 16:24:34xdegayecreate