summaryrefslogtreecommitdiff
path: root/scipy
diff options
context:
space:
mode:
Diffstat (limited to 'scipy')
-rw-r--r--scipy/base/src/arrayobject.c3
-rw-r--r--scipy/base/src/scalartypes.inc.src8
-rw-r--r--scipy/f2py/rules.py4
3 files changed, 11 insertions, 4 deletions
diff --git a/scipy/base/src/arrayobject.c b/scipy/base/src/arrayobject.c
index e49ef8170..41b436ce0 100644
--- a/scipy/base/src/arrayobject.c
+++ b/scipy/base/src/arrayobject.c
@@ -4734,7 +4734,8 @@ _array_find_type(PyObject *op, PyArray_Typecode *minitype,
Py_DECREF(ip);
goto finish;
}
- Py_DECREF(ip);
+ Py_XDECREF(ip);
+ if (PyErr_Occurred()) PyErr_Clear();
}
if (PyInstance_Check(op)) goto deflt;
diff --git a/scipy/base/src/scalartypes.inc.src b/scipy/base/src/scalartypes.inc.src
index 467b32cc5..135b0dcab 100644
--- a/scipy/base/src/scalartypes.inc.src
+++ b/scipy/base/src/scalartypes.inc.src
@@ -126,7 +126,11 @@ gentype_alloc(PyTypeObject *type, int nitems)
const size_t size = _PyObject_VAR_SIZE(type, nitems+1);
obj = (PyObject *)malloc(size);
- PyObject_Init(obj, type);
+ memset(obj, 0, size);
+ if (type->tp_itemsize == 0)
+ PyObject_INIT(obj, type);
+ else
+ (void) PyObject_INIT_VAR((PyVarObject *)obj, type, nitems);
return obj;
}
@@ -1520,7 +1524,9 @@ initialize_numeric_types(void)
PyGenericArrType_Type.tp_getset = gentype_getsets;
PyGenericArrType_Type.tp_new = NULL;
PyGenericArrType_Type.tp_alloc = gentype_alloc;
+ PyStringArrType_Type.tp_alloc = NULL;
PyGenericArrType_Type.tp_free = free;
+ PyStringArrType_Type.tp_free = NULL;
PyGenericArrType_Type.tp_repr = gentype_repr;
PyGenericArrType_Type.tp_str = gentype_str;
PyGenericArrType_Type.tp_richcompare = gentype_richcompare;
diff --git a/scipy/f2py/rules.py b/scipy/f2py/rules.py
index cb2d78e65..5fa9d7c16 100644
--- a/scipy/f2py/rules.py
+++ b/scipy/f2py/rules.py
@@ -991,10 +991,10 @@ if (#varname#_capi==Py_None) {
],
'cleanupfrompyobj':[ # note that this list will be reversed
'\t} /*if (capi_#varname#_tmp == NULL) ... else of #varname#*/',
- {l_not(l_or(isintent_out,isintent_hide)):"""\
+ {l_not(isintent_hide):"""\
\tif((PyObject *)capi_#varname#_tmp!=#varname#_capi) {
\t\tPy_XDECREF(capi_#varname#_tmp); }"""},
- {l_and(isintent_hide,l_not(isintent_out)):"""\t\tPy_XDECREF(capi_#varname#_tmp);"""},
+ {isintent_hide:"""\t\tPy_XDECREF(capi_#varname#_tmp);"""},
{hasinitvalue:'\t} /*if (f2py_success) of #varname# init*/'},
],
'_check':isarray,