Author: Brian Kearns <[email protected]>
Branch:
Changeset: r68531:8f477bbaddf7
Date: 2013-12-23 13:41 -0500
http://bitbucket.org/pypy/pypy/changeset/8f477bbaddf7/
Log: cleanup array/scalar descr_view
diff --git a/pypy/module/micronumpy/interp_boxes.py
b/pypy/module/micronumpy/interp_boxes.py
--- a/pypy/module/micronumpy/interp_boxes.py
+++ b/pypy/module/micronumpy/interp_boxes.py
@@ -7,7 +7,6 @@
from pypy.objspace.std.unicodetype import unicode_typedef, unicode_from_object
from pypy.objspace.std.inttype import int_typedef
from pypy.objspace.std.complextype import complex_typedef
-from pypy.objspace.std.typeobject import W_TypeObject
from rpython.rlib.rarithmetic import LONG_BIT
from rpython.rtyper.lltypesystem import rffi
from rpython.tool.sourcetools import func_with_new_name
@@ -277,8 +276,15 @@
def descr_view(self, space, w_dtype):
from pypy.module.micronumpy.interp_dtype import W_Dtype
- if type(w_dtype) is W_TypeObject and \
- space.abstract_issubclass_w(w_dtype,
space.gettypefor(W_NDimArray)):
+ try:
+ subclass = space.is_true(space.issubtype(
+ w_dtype, space.gettypefor(W_NDimArray)))
+ except OperationError, e:
+ if e.match(space, space.w_TypeError):
+ subclass = False
+ else:
+ raise
+ if subclass:
dtype = self.get_dtype(space)
else:
dtype = space.interp_w(W_Dtype,
diff --git a/pypy/module/micronumpy/interp_numarray.py
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -731,11 +731,15 @@
def descr_view(self, space, w_dtype=None, w_type=None):
if not w_type and w_dtype:
try:
- if space.is_true(space.issubtype(w_dtype,
space.gettypefor(W_NDimArray))):
+ if space.is_true(space.issubtype(
+ w_dtype, space.gettypefor(W_NDimArray))):
w_type = w_dtype
w_dtype = None
- except (OperationError, TypeError):
- pass
+ except OperationError, e:
+ if e.match(space, space.w_TypeError):
+ pass
+ else:
+ raise
if w_dtype:
dtype = space.interp_w(interp_dtype.W_Dtype,
space.call_function(space.gettypefor(interp_dtype.W_Dtype),
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit