Author: Antonio Cuni <[email protected]>
Branch: refactor-str-types
Changeset: r68702:f3faf55d996e
Date: 2014-01-16 22:41 +0100
http://bitbucket.org/pypy/pypy/changeset/f3faf55d996e/
Log: (antocuni, mjacob): fix a corner case
diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py
--- a/pypy/objspace/std/bytesobject.py
+++ b/pypy/objspace/std/bytesobject.py
@@ -65,7 +65,7 @@
"""x.__getitem__(y) <==> x[y]"""
def descr_getnewargs(self, space):
- """"""
+ ""
def descr_getslice(self, space, w_start, w_stop):
"""x.__getslice__(i, j) <==> x[i:j]
diff --git a/pypy/objspace/std/stringmethods.py
b/pypy/objspace/std/stringmethods.py
--- a/pypy/objspace/std/stringmethods.py
+++ b/pypy/objspace/std/stringmethods.py
@@ -45,7 +45,13 @@
return space.newbool(self._val(space).find(self._op_val(space, w_sub))
>= 0)
def descr_add(self, space, w_other):
- return self._new(self._val(space) + self._op_val(space, w_other))
+ try:
+ other = self._op_val(space, w_other)
+ except OperationError, e:
+ if e.match(space, space.w_TypeError):
+ return space.w_NotImplemented
+ raise
+ return self._new(self._val(space) + other)
def descr_mul(self, space, w_times):
try:
diff --git a/pypy/objspace/std/test/test_bytesobject.py
b/pypy/objspace/std/test/test_bytesobject.py
--- a/pypy/objspace/std/test/test_bytesobject.py
+++ b/pypy/objspace/std/test/test_bytesobject.py
@@ -776,6 +776,13 @@
iterable = "hello"
raises(TypeError, len, iter(iterable))
+ def test___radd__(self):
+ class Foo(object):
+ def __radd__(self, other):
+ return 42
+ x = Foo()
+ assert "hello" + x == 42
+
class AppTestPrebuilt(AppTestBytesObject):
spaceconfig = {"objspace.std.withprebuiltchar": True}
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit