[issue21073] Py_ReprEnter potentially misbehaves during malformed thread states

Antoine Pitrou report at bugs.python.org
Thu Mar 27 19:17:43 CET 2014


Antoine Pitrou added the comment:

"hg annotate" shows it dates back to 4f0b7acffc7d by Guido, with the following diff:

diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -150,6 +150,10 @@
 C API
 -----
 
+- PyThreadState_GetDict() was changed not to raise an exception or
+  issue a fatal error when no current thread state is available.  This
+  makes it possible to print dictionaries when no thread is active.
+
 - LONG_LONG was renamed to PY_LONG_LONG.
 
 - Added PyObject_SelfIter() to fill the tp_iter slot for the
diff --git a/Objects/object.c b/Objects/object.c
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -2119,7 +2119,7 @@
 
        dict = PyThreadState_GetDict();
        if (dict == NULL)
-               return -1;
+               return 0;
        list = PyDict_GetItemString(dict, KEY);
        if (list == NULL) {
                list = PyList_New(0);


Unless Guido has changed his mind about it, I'd close this issue as rejected ;-)

----------
nosy: +gvanrossum, pitrou

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


More information about the Python-bugs-list mailing list