Author: mattip <[email protected]>
Branch: dtypes-compatability
Changeset: r78539:c7e922056cff
Date: 2015-07-12 23:10 +0300
http://bitbucket.org/pypy/pypy/changeset/c7e922056cff/
Log: give up with (base_dtype, new_dtype) union spcecification for now,
test for bad param
diff --git a/pypy/module/micronumpy/descriptor.py
b/pypy/module/micronumpy/descriptor.py
--- a/pypy/module/micronumpy/descriptor.py
+++ b/pypy/module/micronumpy/descriptor.py
@@ -729,6 +729,8 @@
w_val = _get_val_or_none(space, w_dict, key)
if w_val is None:
return None
+ if space.isinstance_w(w_val, space.w_set):
+ raise oefmt(space.w_TypeError, "'set' object does not support
indexing")
return space.listview(w_val)
def _usefields(space, w_dict, align):
@@ -922,6 +924,17 @@
return _set_metadata_and_copy(space, w_metadata,
W_Dtype(types.VoidType(space),
space.gettypefor(boxes.W_VoidBox),
shape=shape, subdtype=subdtype, elsize=size))
+ elif w_shape is not None and not space.isinstance_w(w_shape, space.w_int):
+ spec = space.listview(w_shape)
+ if len(spec) > 0:
+ # this is (base_dtype, new_dtype) so just make it a union by
setting both
+ # parts' offset to 0
+ try:
+ dtype1 = make_new_dtype(space, w_subtype, w_shape, alignment)
+ except:
+ raise
+ raise oefmt(space.w_NotImplementedError,
+ "(base_dtype, new_dtype) dtype spectification discouraged, not
implemented")
if space.is_none(w_dtype):
return cache.w_float64dtype
if space.isinstance_w(w_dtype, w_subtype):
diff --git a/pypy/module/micronumpy/test/test_dtypes.py
b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -489,6 +489,8 @@
else:
assert False,'self._ptr_size unknown'
# Issue gh-2798
+ if '__pypy__' in sys.builtin_module_names:
+ skip("(base_dtype, new_dtype) dtype specification discouraged")
a = np.array(['a'], dtype="O").astype(("O", [("name", "O")]))
assert a[0] == 'a'
assert a == 'a'
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit