[pypy-svn] r5099 - pypy/trunk/src/pypy/objspace/std
arigo at codespeak.net
arigo at codespeak.net
Wed Jun 16 13:34:09 CEST 2004
Author: arigo
Date: Wed Jun 16 13:34:08 2004
New Revision: 5099
Modified:
pypy/trunk/src/pypy/objspace/std/longobject.py
Log:
long-to-int delegation allows expression like 'somelist[5L]' to succeed.
Modified: pypy/trunk/src/pypy/objspace/std/longobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/longobject.py (original)
+++ pypy/trunk/src/pypy/objspace/std/longobject.py Wed Jun 16 13:34:08 2004
@@ -25,6 +25,16 @@
delegate__Int.result_class = W_LongObject
delegate__Int.priority = PRIORITY_CHANGE_TYPE
+# long-to-int delegation
+def delegate__Long(space, w_longobj):
+ if -sys.maxint-1 <= w_longobj.longval <= sys.maxint:
+ return W_IntObject(space, int(w_longobj.longval))
+ else:
+ raise OperationError(space.w_OverflowError,
+ space.wrap("long too large to convert to int"))
+delegate__Long.result_class = W_IntObject
+delegate__Long.priority = PRIORITY_CHANGE_TYPE
+
def long__Long(space, w_value):
return w_value
More information about the Pypy-commit
mailing list