mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
PyErr_NoMemory(): If the pre-instantiated memory exception is non-null
(PyExc_MemoryErrorInst) raise this instead of PyExc_MemoryError. This only happens when exception classes are enabled (e.g. when Python is started with -X).
This commit is contained in:
parent
dd82bb9c14
commit
2d8adff10a
1 changed files with 9 additions and 1 deletions
|
@ -256,7 +256,15 @@ PyErr_BadArgument()
|
||||||
PyObject *
|
PyObject *
|
||||||
PyErr_NoMemory()
|
PyErr_NoMemory()
|
||||||
{
|
{
|
||||||
PyErr_SetNone(PyExc_MemoryError);
|
/* raise the pre-allocated instance if it still exists */
|
||||||
|
if (PyExc_MemoryErrorInst)
|
||||||
|
PyErr_SetObject(PyExc_MemoryError, PyExc_MemoryErrorInst);
|
||||||
|
else
|
||||||
|
/* this will probably fail since there's no memory and hee,
|
||||||
|
hee, we have to instantiate this class
|
||||||
|
*/
|
||||||
|
PyErr_SetNone(PyExc_MemoryError);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue