[pypy-commit] pypy numpy-dtype-alt: you can't subclass dtype, thanks fijal
alex_gaynor
noreply at buildbot.pypy.org
Mon Aug 29 18:27:20 CEST 2011
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: numpy-dtype-alt
Changeset: r46894:69827a913a5d
Date: 2011-08-29 12:27 -0400
http://bitbucket.org/pypy/pypy/changeset/69827a913a5d/
Log: you can't subclass dtype, thanks fijal
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
@@ -352,4 +352,5 @@
num = interp_attrproperty("num", cls=W_Dtype),
kind = interp_attrproperty("kind", cls=W_Dtype),
shape = GetSetProperty(W_Dtype.descr_get_shape),
-)
\ No newline at end of file
+)
+W_Dtype.typedef.acceptable_as_base_class = False
\ No newline at end of file
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
@@ -92,4 +92,10 @@
def test_shape(self):
from numpy import dtype
- assert dtype(long).shape == ()
\ No newline at end of file
+ assert dtype(long).shape == ()
+
+ def test_cant_subclass(self):
+ from numpy import dtype
+
+ # You can't subclass dtype
+ raises(TypeError, type, "Foo", (dtype,), {})
\ No newline at end of file
More information about the pypy-commit
mailing list