summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/include/numpy/random/bitgen.h20
-rw-r--r--numpy/core/records.py3
-rw-r--r--numpy/core/src/multiarray/multiarraymodule.c10
-rw-r--r--numpy/core/src/umath/loops.c.src7
4 files changed, 12 insertions, 28 deletions
diff --git a/numpy/core/include/numpy/random/bitgen.h b/numpy/core/include/numpy/random/bitgen.h
deleted file mode 100644
index 0adaaf2ee..000000000
--- a/numpy/core/include/numpy/random/bitgen.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef _RANDOM_BITGEN_H
-#define _RANDOM_BITGEN_H
-
-#pragma once
-#include <stddef.h>
-#include <stdbool.h>
-#include <stdint.h>
-
-/* Must match the declaration in numpy/random/common.pxd */
-
-typedef struct bitgen {
- void *state;
- uint64_t (*next_uint64)(void *st);
- uint32_t (*next_uint32)(void *st);
- double (*next_double)(void *st);
- uint64_t (*next_raw)(void *st);
-} bitgen_t;
-
-
-#endif
diff --git a/numpy/core/records.py b/numpy/core/records.py
index 2b31625c3..8a5fee541 100644
--- a/numpy/core/records.py
+++ b/numpy/core/records.py
@@ -496,8 +496,7 @@ class recarray(ndarray):
except Exception:
fielddict = ndarray.__getattribute__(self, 'dtype').fields or {}
if attr not in fielddict:
- exctype, value = sys.exc_info()[:2]
- raise exctype(value)
+ raise
else:
fielddict = ndarray.__getattribute__(self, 'dtype').fields or {}
if attr not in fielddict:
diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c
index 413decd9d..084a5dd46 100644
--- a/numpy/core/src/multiarray/multiarraymodule.c
+++ b/numpy/core/src/multiarray/multiarraymodule.c
@@ -1581,8 +1581,7 @@ _array_fromobject(PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *kws)
PyArrayObject *oparr = NULL, *ret = NULL;
npy_bool subok = NPY_FALSE;
npy_bool copy = NPY_TRUE;
- int nd;
- npy_intp ndmin = 0;
+ int ndmin = 0, nd;
PyArray_Descr *type = NULL;
PyArray_Descr *oldtype = NULL;
NPY_ORDER order = NPY_KEEPORDER;
@@ -1644,13 +1643,14 @@ _array_fromobject(PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *kws)
ndmin_obj = PyDict_GetItem(kws, npy_ma_str_ndmin);
if (ndmin_obj) {
- ndmin = PyLong_AsLong(ndmin_obj);
- if (error_converting(ndmin)) {
+ long t = PyLong_AsLong(ndmin_obj);
+ if (error_converting(t)) {
goto clean_type;
}
- else if (ndmin > NPY_MAXDIMS) {
+ else if (t > NPY_MAXDIMS) {
goto full_path;
}
+ ndmin = t;
}
/* copy=False with default dtype, order (any is OK) and ndim */
diff --git a/numpy/core/src/umath/loops.c.src b/numpy/core/src/umath/loops.c.src
index f84d74efe..1931cd100 100644
--- a/numpy/core/src/umath/loops.c.src
+++ b/numpy/core/src/umath/loops.c.src
@@ -384,7 +384,11 @@ PyUFunc_O_O_method(char **args, npy_intp *dimensions, npy_intp *steps, void *fun
PyObject **out = (PyObject **)op1;
PyObject *ret, *func;
func = PyObject_GetAttrString(in1 ? in1 : Py_None, meth);
- if (func == NULL || !PyCallable_Check(func)) {
+ if (func != NULL && !PyCallable_Check(func)) {
+ Py_DECREF(func);
+ func = NULL;
+ }
+ if (func == NULL) {
PyObject *exc, *val, *tb;
PyTypeObject *type = in1 ? Py_TYPE(in1) : Py_TYPE(Py_None);
PyErr_Fetch(&exc, &val, &tb);
@@ -397,6 +401,7 @@ PyUFunc_O_O_method(char **args, npy_intp *dimensions, npy_intp *steps, void *fun
return;
}
ret = PyObject_Call(func, tup, NULL);
+ Py_DECREF(func);
if (ret == NULL) {
Py_DECREF(tup);
return;