summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattip <matti.picus@gmail.com>2019-02-26 10:13:51 +0200
committermattip <matti.picus@gmail.com>2019-02-26 10:13:51 +0200
commit3993652c4fd82c3fb2e1ed3f252d0aa77d959d58 (patch)
tree0822bdf9416a1c7641d14ec314b438fd8c9eda0a
parent6f1ecd7729603da193746873e8497d203e7e272d (diff)
downloadnumpy-3993652c4fd82c3fb2e1ed3f252d0aa77d959d58.tar.gz
BUG: fixes from review
-rw-r--r--numpy/core/src/multiarray/descriptor.c6
-rw-r--r--numpy/core/tests/test_dtype.py6
2 files changed, 10 insertions, 2 deletions
diff --git a/numpy/core/src/multiarray/descriptor.c b/numpy/core/src/multiarray/descriptor.c
index a93897198..be4faa691 100644
--- a/numpy/core/src/multiarray/descriptor.c
+++ b/numpy/core/src/multiarray/descriptor.c
@@ -1210,6 +1210,10 @@ _convert_from_dict(PyObject *obj, int align)
new->elsize = totalsize;
if (!PyTuple_Check(names)) {
Py_SETREF(names, PySequence_Tuple(names));
+ if (names == NULL) {
+ Py_DECREF(new);
+ goto fail;
+ }
}
new->names = names;
new->fields = fields;
@@ -1279,7 +1283,7 @@ _convert_from_dict(PyObject *obj, int align)
else {
int ret = PyDict_Merge(new->metadata, metadata, 0);
Py_DECREF(metadata);
- if (ret == -1) {
+ if (ret < 0) {
Py_DECREF(new);
goto fail;
}
diff --git a/numpy/core/tests/test_dtype.py b/numpy/core/tests/test_dtype.py
index b4008acf2..071aa1ab8 100644
--- a/numpy/core/tests/test_dtype.py
+++ b/numpy/core/tests/test_dtype.py
@@ -215,7 +215,6 @@ class TestRecord(object):
assert_equal(dt1.descr, [('a', '|i1'), ('', '|V3'),
('b', [('f0', '<i2'), ('', '|V2'),
('f1', '<f4')], (2,))])
-
def test_union_struct(self):
# Should be able to create union dtypes
@@ -321,6 +320,11 @@ class TestRecord(object):
assert_equal(dt[1], dt[np.int8(1)])
+ def test_partial_dict(self):
+ # 'name' is missing
+ assert_raises(ValueError, np.dtype,
+ {'formats': ['i4', 'i4'], 'f0': ('i4', 0), 'f1':('i4', 4)})
+
class TestSubarray(object):
def test_single_subarray(self):