[pypy-commit] pypy default: a test and a fix for boxes identity
fijal
noreply at buildbot.pypy.org
Wed Jan 25 17:28:52 CET 2012
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch:
Changeset: r51766:3890a6e149fa
Date: 2012-01-25 18:28 +0200
http://bitbucket.org/pypy/pypy/changeset/3890a6e149fa/
Log: a test and a fix for boxes identity
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
@@ -9,6 +9,7 @@
MIXIN_64 = (int_typedef,) if LONG_BIT == 64 else ()
+MIXIN_32 = () if LONG_BIT == 64 else (int_typedef,)
def new_dtype_getter(name):
def get_dtype(space):
@@ -231,7 +232,7 @@
__new__ = interp2app(W_UInt16Box.descr__new__.im_func),
)
-W_Int32Box.typedef = TypeDef("int32", W_SignedIntegerBox.typedef,
+W_Int32Box.typedef = TypeDef("int32", (W_SignedIntegerBox.typedef,) + MIXIN_32,
__module__ = "numpypy",
__new__ = interp2app(W_Int32Box.descr__new__.im_func),
)
@@ -241,24 +242,18 @@
__new__ = interp2app(W_UInt32Box.descr__new__.im_func),
)
-if LONG_BIT == 32:
- long_name = "int32"
-elif LONG_BIT == 64:
- long_name = "int64"
-W_LongBox.typedef = TypeDef(long_name, (W_SignedIntegerBox.typedef, int_typedef,),
- __module__ = "numpypy",
- __new__ = interp2app(W_LongBox.descr__new__.im_func),
-)
-
-W_ULongBox.typedef = TypeDef("u" + long_name, W_UnsignedIntegerBox.typedef,
- __module__ = "numpypy",
-)
-
W_Int64Box.typedef = TypeDef("int64", (W_SignedIntegerBox.typedef,) + MIXIN_64,
__module__ = "numpypy",
__new__ = interp2app(W_Int64Box.descr__new__.im_func),
)
+if LONG_BIT == 32:
+ W_LongBox = W_Int32Box
+ W_ULongBox = W_UInt32Box
+elif LONG_BIT == 64:
+ W_LongBox = W_Int64Box
+ W_ULongBox = W_UInt64Box
+
W_UInt64Box.typedef = TypeDef("uint64", W_UnsignedIntegerBox.typedef,
__module__ = "numpypy",
__new__ = interp2app(W_UInt64Box.descr__new__.im_func),
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
@@ -376,3 +376,14 @@
b = X(10)
assert type(b) is X
assert b.m() == 12
+
+ def test_int(self):
+ import sys
+ from _numpypy import int32, int64, int_
+ assert issubclass(int_, int)
+ if sys.maxint == (1<<31) - 1:
+ assert issubclass(int32, int)
+ assert int_ is int32
+ else:
+ assert issubclass(int64, int)
+ assert int_ is int64
More information about the pypy-commit
mailing list