diff options
author | Guido van Rossum <guido@python.org> | 2003-04-15 15:12:39 +0000 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2003-04-15 15:12:39 +0000 |
commit | 442365983beef2a9e8713bf1022201fec42cd42e (patch) | |
tree | e69fc332afc0bd43e437c2332e2c7ae0681158ea /Python/pystate.c | |
parent | ff921d0572cd70788442e36236776108e027dcba (diff) | |
download | cpython-442365983beef2a9e8713bf1022201fec42cd42e.tar.gz |
- 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.
Diffstat (limited to 'Python/pystate.c')
-rw-r--r-- | Python/pystate.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Python/pystate.c b/Python/pystate.c index 1139851c3c..62bf09b626 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -266,17 +266,21 @@ PyThreadState_Swap(PyThreadState *new) /* An extension mechanism to store arbitrary additional per-thread state. 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. */ + PyThreadState_GetDict() returns NULL, an exception has *not* been raised + and the caller should assume no per-thread state is available. */ PyObject * PyThreadState_GetDict(void) { if (_PyThreadState_Current == NULL) - Py_FatalError("PyThreadState_GetDict: no current thread"); + return NULL; - if (_PyThreadState_Current->dict == NULL) - _PyThreadState_Current->dict = PyDict_New(); + if (_PyThreadState_Current->dict == NULL) { + PyObject *d; + _PyThreadState_Current->dict = d = PyDict_New(); + if (d == NULL) + PyErr_Clear(); + } return _PyThreadState_Current->dict; } |