[pypy-commit] pypy py3k: bah, ints are now W_LongObject, so this multimethod was never called. Adapt it to deal with longs
antocuni
noreply at buildbot.pypy.org
Wed Mar 21 16:09:33 CET 2012
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: py3k
Changeset: r53871:b113dbf5ff2e
Date: 2012-03-21 16:09 +0100
http://bitbucket.org/pypy/pypy/changeset/b113dbf5ff2e/
Log: bah, ints are now W_LongObject, so this multimethod was never
called. Adapt it to deal with longs
diff --git a/pypy/objspace/std/stringobject.py b/pypy/objspace/std/stringobject.py
--- a/pypy/objspace/std/stringobject.py
+++ b/pypy/objspace/std/stringobject.py
@@ -9,7 +9,7 @@
from pypy.objspace.std.inttype import wrapint
from pypy.objspace.std.sliceobject import W_SliceObject, normalize_simple_slice
from pypy.objspace.std import slicetype, newformat
-from pypy.objspace.std.intobject import W_IntObject
+from pypy.objspace.std.longobject import W_LongObject
from pypy.objspace.std.listobject import W_ListObject
from pypy.objspace.std.noneobject import W_NoneObject
from pypy.objspace.std.tupleobject import W_TupleObject
@@ -457,9 +457,16 @@
sub = w_sub._value
return space.newbool(self.find(sub) >= 0)
-def contains__String_Int(space, w_self, w_char):
+def contains__String_Long(space, w_self, w_char):
self = w_self._value
- char = w_char.intval
+ try:
+ char = space.int_w(w_char)
+ except OperationError, e:
+ if e.match(space, space.w_OverflowError):
+ char = 256 # arbitrary value which will trigger the ValueError
+ # condition below
+ else:
+ raise
if 0 <= char < 256:
return space.newbool(self.find(chr(char)) >= 0)
else:
More information about the pypy-commit
mailing list