[pypy-commit] pypy default: fix segfault when accessing real/imag views of nonnative complex types

bdkearns noreply at buildbot.pypy.org
Tue Oct 29 05:35:22 CET 2013


Author: Brian Kearns <bdkearns at gmail.com>
Branch: 
Changeset: r67673:0e1c4dd7f78d
Date: 2013-10-28 23:23 -0400
http://bitbucket.org/pypy/pypy/changeset/0e1c4dd7f78d/

Log:	fix segfault when accessing real/imag views of nonnative complex
	types

diff --git a/pypy/module/micronumpy/interp_dtype.py b/pypy/module/micronumpy/interp_dtype.py
--- a/pypy/module/micronumpy/interp_dtype.py
+++ b/pypy/module/micronumpy/interp_dtype.py
@@ -50,7 +50,7 @@
     return out
 
 class W_Dtype(W_Root):
-    _immutable_fields_ = ["itemtype?", "num", "kind", "name?", "char", "w_box_type", "byteorder"]
+    _immutable_fields_ = ["itemtype?", "num", "kind", "name?", "char", "w_box_type", "byteorder", "float_type"]
 
     def __init__(self, itemtype, num, kind, name, char, w_box_type, byteorder='=',
                  alternate_constructors=[], aliases=[], float_type=None,
@@ -749,7 +749,7 @@
             self.dtypes_by_name[new_name] = W_Dtype(
                 itemtype,
                 dtype.num, dtype.kind, new_name, dtype.char, dtype.w_box_type,
-                byteorder=OPPBYTE)
+                byteorder=OPPBYTE, float_type=dtype.float_type)
             if dtype.kind != dtype.char:
                 can_name = dtype.char
                 self.dtypes_by_name[NATBYTE + can_name] = dtype
@@ -758,7 +758,7 @@
                 self.dtypes_by_name[new_name] = W_Dtype(
                     itemtype,
                     dtype.num, dtype.kind, new_name, dtype.char, dtype.w_box_type,
-                    byteorder=OPPBYTE)
+                    byteorder=OPPBYTE, float_type=dtype.float_type)
 
             for alias in dtype.aliases:
                 self.dtypes_by_name[alias] = dtype
diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -1466,6 +1466,11 @@
         assert a[3].imag == -10
         assert a[2].imag == -5
 
+        assert arange(4, dtype='>c8').imag.max() == 0.0
+        assert arange(4, dtype='<c8').imag.max() == 0.0
+        assert arange(4, dtype='>c8').real.max() == 3.0
+        assert arange(4, dtype='<c8').real.max() == 3.0
+
     def test_trace(self):
         import numpypy as np
         assert np.trace(np.eye(3)) == 3.0


More information about the pypy-commit mailing list