Mercurial > cpython-lru_cache-weakref
comparison Modules/arraymodule.c @ 87092:285d28c3620a
Issue #19437: Fix array.buffer_info(), handle PyLong_FromVoidPtr() and
PyLong_FromLong() failure
| author | Victor Stinner <victor.stinner@gmail.com> |
|---|---|
| date | Thu, 14 Nov 2013 01:27:12 +0100 |
| parents | e7f6cef7a4cc |
| children | 2c87d3944c7a |
comparison
equal
deleted
inserted
replaced
| 87091:7d0323556c53 | 87092:285d28c3620a |
|---|---|
| 1131 | 1131 |
| 1132 | 1132 |
| 1133 static PyObject * | 1133 static PyObject * |
| 1134 array_buffer_info(arrayobject *self, PyObject *unused) | 1134 array_buffer_info(arrayobject *self, PyObject *unused) |
| 1135 { | 1135 { |
| 1136 PyObject* retval = NULL; | 1136 PyObject *retval = NULL, *v; |
| 1137 | |
| 1137 retval = PyTuple_New(2); | 1138 retval = PyTuple_New(2); |
| 1138 if (!retval) | 1139 if (!retval) |
| 1139 return NULL; | 1140 return NULL; |
| 1140 | 1141 |
| 1141 PyTuple_SET_ITEM(retval, 0, PyLong_FromVoidPtr(self->ob_item)); | 1142 v = PyLong_FromVoidPtr(self->ob_item); |
| 1142 PyTuple_SET_ITEM(retval, 1, PyLong_FromLong((long)(Py_SIZE(self)))); | 1143 if (v == NULL) { |
| 1144 Py_DECREF(retval); | |
| 1145 return NULL; | |
| 1146 } | |
| 1147 PyTuple_SET_ITEM(retval, 0, v); | |
| 1148 | |
| 1149 v = PyLong_FromLong((long)(Py_SIZE(self))); | |
| 1150 if (v == NULL) { | |
| 1151 Py_DECREF(retval); | |
| 1152 return NULL; | |
| 1153 } | |
| 1154 PyTuple_SET_ITEM(retval, 1, v); | |
| 1143 | 1155 |
| 1144 return retval; | 1156 return retval; |
| 1145 } | 1157 } |
| 1146 | 1158 |
| 1147 PyDoc_STRVAR(buffer_info_doc, | 1159 PyDoc_STRVAR(buffer_info_doc, |
