[Python-checkins] python/dist/src/Python pystate.c,2.24,2.25
gvanrossum@users.sourceforge.net
gvanrossum@users.sourceforge.net
Tue, 15 Apr 2003 08:12:42 -0700
Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1:/tmp/cvs-serv30985/Python
Modified Files:
pystate.c
Log Message:
- pythunrun.c, Py_Finalize(): move the call to _Py_PrintReferences()
even farther down, to just before the call to
_PyObject_DebugMallocStats(). This required the following changes:
- pystate.c, PyThreadState_GetDict(): changed not to raise an
exception or issue a fatal error when no current thread state is
available, but simply return NULL without raising an exception
(ever).
- object.c, Py_ReprEnter(): when PyThreadState_GetDict() returns NULL,
don't raise an exception but return 0. This means that when
printing a container that's recursive, printing will go on and on
and on. But that shouldn't happen in the case we care about (see
first bullet).
- Updated Misc/NEWS and Doc/api/init.tex to reflect changes to
PyThreadState_GetDict() definition.
Index: pystate.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/pystate.c,v
retrieving revision 2.24
retrieving revision 2.25
diff -C2 -d -r2.24 -r2.25
*** pystate.c 19 Mar 2003 00:35:36 -0000 2.24
--- pystate.c 15 Apr 2003 15:12:39 -0000 2.25
***************
*** 267,272 ****
PyThreadState_GetDict() returns a dictionary that can be used to hold such
state; the caller should pick a unique key and store its state there. If
! PyThreadState_GetDict() returns NULL, an exception has been raised (most
! likely MemoryError) and the caller should pass on the exception. */
PyObject *
--- 267,272 ----
PyThreadState_GetDict() returns a dictionary that can be used to hold such
state; the caller should pick a unique key and store its state there. If
! PyThreadState_GetDict() returns NULL, an exception has *not* been raised
! and the caller should assume no per-thread state is available. */
PyObject *
***************
*** 274,281 ****
{
if (_PyThreadState_Current == NULL)
! Py_FatalError("PyThreadState_GetDict: no current thread");
! if (_PyThreadState_Current->dict == NULL)
! _PyThreadState_Current->dict = PyDict_New();
return _PyThreadState_Current->dict;
}
--- 274,285 ----
{
if (_PyThreadState_Current == NULL)
! return NULL;
! if (_PyThreadState_Current->dict == NULL) {
! PyObject *d;
! _PyThreadState_Current->dict = d = PyDict_New();
! if (d == NULL)
! PyErr_Clear();
! }
return _PyThreadState_Current->dict;
}