diff options
author | Mark Wiebe <mwiebe@enthought.com> | 2011-06-01 16:47:49 -0500 |
---|---|---|
committer | Mark Wiebe <mwiebe@enthought.com> | 2011-06-01 16:47:49 -0500 |
commit | 653c6454a69f75e13b65f3d9a9eea48dbcbab6c3 (patch) | |
tree | 41909429fb7810e1e16dcb60884a61d740ea7914 | |
parent | 3dd1018f1d0a51632d91127276631b32e3fed1e8 (diff) | |
download | numpy-653c6454a69f75e13b65f3d9a9eea48dbcbab6c3.tar.gz |
ENH: Remove dead code in PyArray_SetDatetimeParseFunction
-rw-r--r-- | numpy/core/src/multiarray/arrayobject.c | 9 | ||||
-rw-r--r-- | numpy/core/src/multiarray/multiarraymodule.c | 33 | ||||
-rw-r--r-- | numpy/core/src/multiarray/scalartypes.c.src | 22 |
3 files changed, 16 insertions, 48 deletions
diff --git a/numpy/core/src/multiarray/arrayobject.c b/numpy/core/src/multiarray/arrayobject.c index a3008c888..f75759593 100644 --- a/numpy/core/src/multiarray/arrayobject.c +++ b/numpy/core/src/multiarray/arrayobject.c @@ -380,7 +380,6 @@ array_repr_builtin(PyArrayObject *self, int repr) static PyObject *PyArray_StrFunction = NULL; static PyObject *PyArray_ReprFunction = NULL; -static PyObject *PyArray_DatetimeParseFunction = NULL; /*NUMPY_API * Set the array print function to be a Python function. @@ -407,17 +406,11 @@ PyArray_SetStringFunction(PyObject *op, int repr) } /*NUMPY_API - * Set the date time print function to be a Python function. + * This function is scheduled to be removed */ NPY_NO_EXPORT void PyArray_SetDatetimeParseFunction(PyObject *op) { - /* Dispose of previous callback */ - Py_XDECREF(PyArray_DatetimeParseFunction); - /* Add a reference to the new callback */ - Py_XINCREF(op); - /* Remember new callback */ - PyArray_DatetimeParseFunction = op; } diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c index 523cb0581..6a1cc5e9d 100644 --- a/numpy/core/src/multiarray/multiarraymodule.c +++ b/numpy/core/src/multiarray/multiarraymodule.c @@ -2537,36 +2537,11 @@ array_set_ops_function(PyObject *NPY_UNUSED(self), PyObject *NPY_UNUSED(args), } static PyObject * -array_set_datetimeparse_function(PyObject *NPY_UNUSED(self), PyObject *args, - PyObject *kwds) +array_set_datetimeparse_function(PyObject *NPY_UNUSED(self), + PyObject *NPY_UNUSED(args), PyObject *NPY_UNUSED(kwds)) { - PyObject *op = NULL; - static char *kwlist[] = {"f", NULL}; - PyObject *_numpy_internal; - - if(!PyArg_ParseTupleAndKeywords(args, kwds, "|O", kwlist, &op)) { - return NULL; - } - /* reset the array_repr function to built-in */ - if (op == Py_None) { - _numpy_internal = PyImport_ImportModule("numpy.core._internal"); - if (_numpy_internal == NULL) { - return NULL; - } - op = PyObject_GetAttrString(_numpy_internal, "datetime_from_string"); - } - else { /* Must balance reference count increment in both branches */ - if (!PyCallable_Check(op)) { - PyErr_SetString(PyExc_TypeError, - "Argument must be callable."); - return NULL; - } - Py_INCREF(op); - } - PyArray_SetDatetimeParseFunction(op); - Py_DECREF(op); - Py_INCREF(Py_None); - return Py_None; + PyErr_SetString(PyExc_RuntimeError, "This function is to be removed"); + return NULL; } diff --git a/numpy/core/src/multiarray/scalartypes.c.src b/numpy/core/src/multiarray/scalartypes.c.src index d6ee85df0..34962b744 100644 --- a/numpy/core/src/multiarray/scalartypes.c.src +++ b/numpy/core/src/multiarray/scalartypes.c.src @@ -107,7 +107,7 @@ gentype_alloc(PyTypeObject *type, Py_ssize_t nitems) PyObject *obj; const size_t size = _PyObject_VAR_SIZE(type, nitems + 1); - obj = (PyObject *)_pya_malloc(size); + obj = (PyObject *)PyArray_malloc(size); memset(obj, 0, size); if (type->tp_itemsize == 0) { PyObject_INIT(obj, type); @@ -909,8 +909,8 @@ gentype_struct_free(PyObject *ptr) context = (PyObject *)PyCapsule_GetContext(ptr); Py_DECREF(context); Py_XDECREF(arrif->descr); - _pya_free(arrif->shape); - _pya_free(arrif); + PyArray_free(arrif->shape); + PyArray_free(arrif); } #else NPY_NO_EXPORT void @@ -919,8 +919,8 @@ gentype_struct_free(void *ptr, void *arg) PyArrayInterface *arrif = (PyArrayInterface *)ptr; Py_DECREF((PyObject *)arg); Py_XDECREF(arrif->descr); - _pya_free(arrif->shape); - _pya_free(arrif); + PyArray_free(arrif->shape); + PyArray_free(arrif); } #endif @@ -932,7 +932,7 @@ gentype_struct_get(PyObject *self) PyObject *ret; arr = (PyArrayObject *)PyArray_FromScalar(self, NULL); - inter = (PyArrayInterface *)_pya_malloc(sizeof(PyArrayInterface)); + inter = (PyArrayInterface *)PyArray_malloc(sizeof(PyArrayInterface)); inter->two = 2; inter->nd = 0; inter->flags = arr->flags; @@ -1296,7 +1296,7 @@ gentype_byteswap(PyObject *self, PyObject *args) gentype_getreadbuf(self, 0, (void **)&data); descr = PyArray_DescrFromScalar(self); - newmem = _pya_malloc(descr->elsize); + newmem = PyArray_malloc(descr->elsize); if (newmem == NULL) { Py_DECREF(descr); return PyErr_NoMemory(); @@ -1305,7 +1305,7 @@ gentype_byteswap(PyObject *self, PyObject *args) descr->f->copyswap(newmem, data, 1, NULL); } new = PyArray_Scalar(newmem, descr, NULL); - _pya_free(newmem); + PyArray_free(newmem); Py_DECREF(descr); return new; } @@ -1478,7 +1478,7 @@ gentype_reduce(PyObject *self, PyObject *NPY_UNUSED(args)) int newlen; if (PyArray_IsScalar(self, Unicode)) { - tmp = _pya_malloc(buflen*2); + tmp = PyArray_malloc(buflen*2); if (tmp == NULL) { Py_DECREF(ret); return PyErr_NoMemory(); @@ -1505,7 +1505,7 @@ gentype_reduce(PyObject *self, PyObject *NPY_UNUSED(args)) Py_BuildValue("NN", obj, mod)); #ifndef Py_UNICODE_WIDE fail: - if (alloc) _pya_free((char *)buffer); + if (alloc) PyArray_free((char *)buffer); #endif } return ret; @@ -3678,7 +3678,7 @@ initialize_numeric_types(void) PyGenericArrType_Type.tp_getset = gentype_getsets; PyGenericArrType_Type.tp_new = NULL; PyGenericArrType_Type.tp_alloc = gentype_alloc; - PyGenericArrType_Type.tp_free = _pya_free; + PyGenericArrType_Type.tp_free = PyArray_free; PyGenericArrType_Type.tp_repr = gentype_repr; PyGenericArrType_Type.tp_str = gentype_str; PyGenericArrType_Type.tp_richcompare = gentype_richcompare; |