[pypy-commit] pypy numpy-dtype-alt: fix for unknown dtype

alex_gaynor noreply at buildbot.pypy.org
Thu Aug 25 20:02:16 CEST 2011


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: numpy-dtype-alt
Changeset: r46771:05ba07731112
Date: 2011-08-25 14:08 -0400
http://bitbucket.org/pypy/pypy/changeset/05ba07731112/

Log:	fix for unknown dtype

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
@@ -2,6 +2,7 @@
 import math
 
 from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.error import OperationError
 from pypy.interpreter.gateway import interp2app
 from pypy.interpreter.typedef import TypeDef, interp_attrproperty
 from pypy.module.micronumpy import signature
@@ -35,7 +36,7 @@
             for typename, dtype_class in dtypes_by_apptype:
                 if space.is_w(getattr(space, "w_%s" % typename), w_dtype):
                     return space.fromcache(dtype_class)
-        assert False
+        raise OperationError(space.w_TypeError, space.wrap("data type not understood"))
 
     def descr_repr(self, space):
         return space.wrap("dtype('%s')" % self.name)
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
@@ -13,6 +13,7 @@
         assert dtype('int8').num == 1
         assert dtype(d) is d
         assert dtype(None) is dtype(float)
+        raises(TypeError, dtype, 1042)
 
     def test_dtype_with_types(self):
         from numpy import dtype


More information about the pypy-commit mailing list