[issue9295] test_close_open_print_buffered(test_file) sometimes crashes

Antoine Pitrou report at bugs.python.org
Sun Jul 18 21:09:44 CEST 2010


Antoine Pitrou <pitrou at free.fr> added the comment:

Does the following patch solve your issue?


Index: Python/ceval.c
===================================================================
--- Python/ceval.c	(révision 82959)
+++ Python/ceval.c	(copie de travail)
@@ -1763,6 +1763,8 @@
                If __getattr__ raises an exception, w will
                be freed, so we need to prevent that temporarily. */
             Py_XINCREF(w);
+            if (PyFile_Check(w))
+                PyFile_IncUseCount((PyFileObject *) w);
             if (w != NULL && PyFile_SoftSpace(w, 0))
                 err = PyFile_WriteString(" ", w);
             if (err == 0)
@@ -1790,6 +1792,8 @@
                 else
                     PyFile_SoftSpace(w, 1);
             }
+            if (PyFile_Check(w))
+                PyFile_DecUseCount((PyFileObject *) w);
             Py_XDECREF(w);
             Py_DECREF(v);
             Py_XDECREF(stream);

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9295>
_______________________________________


More information about the Python-bugs-list mailing list