[pypy-svn] r37749 - in pypy/dist/pypy/objspace/std: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Thu Feb 1 16:43:01 CET 2007


Author: cfbolz
Date: Thu Feb  1 16:43:01 2007
New Revision: 37749

Modified:
   pypy/dist/pypy/objspace/std/strjoinobject.py
   pypy/dist/pypy/objspace/std/test/test_strjoinobject.py
Log:
yet another str join bug :-(


Modified: pypy/dist/pypy/objspace/std/strjoinobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/strjoinobject.py	(original)
+++ pypy/dist/pypy/objspace/std/strjoinobject.py	Thu Feb  1 16:43:01 2007
@@ -50,7 +50,7 @@
 def add__StringJoin_StringJoin(space, w_self, w_other):
     if len(w_self.joined_strs) > w_self.until:
         w_self.force(True)
-    w_self.joined_strs.extend(w_other.joined_strs)
+    w_self.joined_strs.extend(w_other.joined_strs[:w_other.until])
     return W_StringJoinObject(w_self.joined_strs)
 
 def add__StringJoin_String(space, w_self, w_other):
@@ -60,14 +60,10 @@
     w_self.joined_strs.append(other)
     return W_StringJoinObject(w_self.joined_strs)
 
-#def add__String_StringJoin(space, w_other, w_self):
-#    other = space.str_w(w_other)
-#    return W_StringObject([other] + w_self.joined_strs)
-
 def str__StringJoin(space, w_str):
-    if type(w_str) is W_StringJoinObject:
-        return w_str
-    return W_StringJoinObject(w_str.joined_strs)
+    # you cannot get subclasses of W_StringObject here
+    assert type(w_str) is W_StringJoinObject
+    return w_str
 
 from pypy.objspace.std import stringtype
 register_all(vars(), stringtype)

Modified: pypy/dist/pypy/objspace/std/test/test_strjoinobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_strjoinobject.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_strjoinobject.py	Thu Feb  1 16:43:01 2007
@@ -62,3 +62,11 @@
         u = s + 'd'
         v = s + 'e'
         assert v == 'abe' # meaning u is abcd
+
+    def test_buh_even_more(self):
+        a = 'a' + 'b'
+        b = a + 'c'
+        c = '0' + '1'
+        x = c + a
+        assert x == '01ab'
+



More information about the Pypy-commit mailing list