diff options
| author | Guido van Rossum <guido@python.org> | 2002-10-11 20:37:58 +0000 |
|---|---|---|
| committer | Guido van Rossum <guido@python.org> | 2002-10-11 20:37:58 +0000 |
| commit | e5be24ca18062267ba675156029e5814f511cf5b (patch) | |
| tree | 0a0c926142ce0dd28ec50ef4b96d5ce35aaa3586 /Objects | |
| parent | 1759eb778e6da09d90085779f20b68a7375d16cd (diff) | |
| download | cpython-git-e5be24ca18062267ba675156029e5814f511cf5b.tar.gz | |
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.
Diffstat (limited to 'Objects')
| -rw-r--r-- | Objects/object.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/Objects/object.c b/Objects/object.c index 27efb4ad24..51801d80a2 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -99,11 +99,8 @@ inc_count(PyTypeObject *tp) 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 @@ PyObject_Init(PyObject *op, PyTypeObject *tp) 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; |
