Mercurial > cpython-lru_cache-weakref
diff Objects/object.c @ 25738:eeed7c8b231a 2.2
Backport 2.193:
PyObject_Init[Var] is almost always called from the PyObject_NEW[_VAR]
macros. The 'op' argument is then the result from PyObject_MALLOC,
and that can of course be NULL. In that case, PyObject_Init[Var]
would raise a SystemError with "NULL object passed to
PyObject_Init[Var]". But there's nothing the caller of the macro can
do about this. So PyObject_Init[Var] should call just PyErr_NoMemory.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 11 Oct 2002 20:37:58 +0000 |
| parents | 718909121737 |
| children | f6e46585b6b3 |
line wrap: on
line diff
--- a/Objects/object.c Fri Oct 11 18:38:20 2002 +0000 +++ b/Objects/object.c Fri Oct 11 20:37:58 2002 +0000 @@ -99,11 +99,8 @@ PyObject * PyObject_Init(PyObject *op, PyTypeObject *tp) { - if (op == NULL) { - PyErr_SetString(PyExc_SystemError, - "NULL object passed to PyObject_Init"); - return op; - } + if (op == NULL) + return PyErr_NoMemory(); /* Any changes should be reflected in PyObject_INIT (objimpl.h) */ op->ob_type = tp; _Py_NewReference(op); @@ -113,11 +110,8 @@ PyVarObject * PyObject_InitVar(PyVarObject *op, PyTypeObject *tp, int size) { - if (op == NULL) { - PyErr_SetString(PyExc_SystemError, - "NULL object passed to PyObject_InitVar"); - return op; - } + if (op == NULL) + return (PyVarObject *) PyErr_NoMemory(); /* Any changes should be reflected in PyObject_INIT_VAR */ op->ob_size = size; op->ob_type = tp;
