Author: Antonio Cuni <[email protected]>
Branch: cpyext-avoid-roundtrip
Changeset: r92669:f91e599505d5
Date: 2017-10-09 09:00 +0200
http://bitbucket.org/pypy/pypy/changeset/f91e599505d5/

Log:    try to be a bit more similar to CPython and raise PyExc_NoMem()
        inside _PyObject_NewVar() instead of PyObject_Init*()

diff --git a/pypy/module/cpyext/src/object.c b/pypy/module/cpyext/src/object.c
--- a/pypy/module/cpyext/src/object.c
+++ b/pypy/module/cpyext/src/object.c
@@ -123,6 +123,9 @@
     else
         py_obj = _generic_alloc(type, nitems);
 
+    if (!py_obj)
+        return (PyVarObject*)PyErr_NoMemory();
+    
     if (type->tp_itemsize == 0)
         return PyObject_Init(py_obj, type);
     else
@@ -132,8 +135,6 @@
 PyObject *
 PyObject_Init(PyObject *obj, PyTypeObject *type)
 {
-    if (!obj)
-        PyErr_NoMemory();
     obj->ob_type = type;
     obj->ob_pypy_link = 0;
     obj->ob_refcnt = 1;
@@ -143,8 +144,6 @@
 PyVarObject *
 PyObject_InitVar(PyVarObject *obj, PyTypeObject *type, Py_ssize_t size)
 {
-    if (!obj)
-        PyErr_NoMemory();
     obj->ob_size = size;
     return PyObject_Init((PyObject*)obj, type);
 }
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to