[NumPy-Tickets] [NumPy] #1770: Segfault with python 3.2 structured array non-existent field
NumPy Trac
numpy-tickets@scipy....
Sun Mar 13 14:06:30 CDT 2011
#1770: Segfault with python 3.2 structured array non-existent field
---------------------------+------------------------------------------------
Reporter: matthew.brett | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: Unscheduled
Component: Other | Version: devel
Keywords: |
---------------------------+------------------------------------------------
{{{
$ python3.2
Python 3.2 (r32:88452, Feb 20 2011, 11:12:31)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> a = np.zeros((1,), dtype=[('f1', 'f')])
>>> a['f1'] = 1
>>> a['f2'] = 1
Segmentation fault
}}}
All tests pass with np.test()
Expected behavior with same code on python2.6:
{{{
>>> a['f2'] = 1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: field named f2 not found.
}}}
Discussion on the mailing list with email of same title as this ticket.
Christoph Gohlke suggested the following patch:
{{{
diff --git a/numpy/core/src/multiarray/mapping.c
b/numpy/core/src/multiarray/mapping.c
index 8db85bf..3a72811 100644
--- a/numpy/core/src/multiarray/mapping.c
+++ b/numpy/core/src/multiarray/mapping.c
@@ -812,10 +812,16 @@ array_ass_sub(PyArrayObject *self, PyObject *index,
PyObject *op)
}
}
}
-
+#if defined(NPY_PY3K)
+ PyErr_Format(PyExc_ValueError,
+ "field named %S not found.",
+ index);
+#else
PyErr_Format(PyExc_ValueError,
"field named %s not found.",
PyString_AsString(index));
+#endif
+
return -1;
}
}}}
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1770>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list