[pypy-svn] r58739 - in pypy/branch/2.5-merge/pypy/objspace/std: . test
arigo at codespeak.net
arigo at codespeak.net
Tue Oct 7 14:34:26 CEST 2008
Author: arigo
Date: Tue Oct 7 14:34:25 2008
New Revision: 58739
Modified:
pypy/branch/2.5-merge/pypy/objspace/std/longtype.py
pypy/branch/2.5-merge/pypy/objspace/std/test/test_longobject.py
Log:
(jlg, arigo)
Test and fix for subclasses of 'long' that override __long__().
Modified: pypy/branch/2.5-merge/pypy/objspace/std/longtype.py
==============================================================================
--- pypy/branch/2.5-merge/pypy/objspace/std/longtype.py (original)
+++ pypy/branch/2.5-merge/pypy/objspace/std/longtype.py Tue Oct 7 14:34:25 2008
@@ -8,7 +8,7 @@
w_value = w_x # 'x' is the keyword argument name in CPython
if w_base is None:
# check for easy cases
- if isinstance(w_value, W_LongObject):
+ if type(w_value) is W_LongObject:
pass
elif space.is_true(space.isinstance(w_value, space.w_str)):
try:
Modified: pypy/branch/2.5-merge/pypy/objspace/std/test/test_longobject.py
==============================================================================
--- pypy/branch/2.5-merge/pypy/objspace/std/test/test_longobject.py (original)
+++ pypy/branch/2.5-merge/pypy/objspace/std/test/test_longobject.py Tue Oct 7 14:34:25 2008
@@ -194,3 +194,12 @@
raises(OverflowError, float, huge)
raises(OverflowError, operator.truediv, huge, 3)
raises(OverflowError, operator.truediv, huge, 3L)
+
+ def test_override___long__(self):
+ class mylong(long):
+ def __long__(self):
+ return 42L
+ assert long(mylong(21)) == 42L
+ class myotherlong(long):
+ pass
+ assert long(myotherlong(21)) == 21L
More information about the Pypy-commit
mailing list