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

mwh at codespeak.net mwh at codespeak.net
Fri Dec 22 11:02:24 CET 2006


Author: mwh
Date: Fri Dec 22 11:02:21 2006
New Revision: 35945

Modified:
   pypy/dist/pypy/objspace/std/strjoinobject.py
   pypy/dist/pypy/objspace/std/test/test_strjoinobject.py
Log:
fix a bug in add_StringJoin_StringJoin that was identical to the last bug fixed
in add_StringJoin_String.


Modified: pypy/dist/pypy/objspace/std/strjoinobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/strjoinobject.py	(original)
+++ pypy/dist/pypy/objspace/std/strjoinobject.py	Fri Dec 22 11:02:21 2006
@@ -48,6 +48,8 @@
     return w_str.force()
 
 def add__StringJoin_StringJoin(space, w_self, w_other):
+    if len(w_self.joined_strs) > w_self.until:
+        w_self.force()
     w_self.joined_strs.extend(w_other.joined_strs)
     return W_StringJoinObject(w_self.joined_strs)
 

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	Fri Dec 22 11:02:21 2006
@@ -42,3 +42,16 @@
         r = "c" + "d"
         t = s + r
         assert len(s) == 2
+
+    def test_add_strjoin_strjoin(self):
+        # make three strjoin objects
+        s = 'a' + 'b'
+        t = 'c' + 'd'
+        u = 'e' + 'f'
+
+        # add two different strjoins to the same string
+        v = s + t
+        w = s + u
+
+        # check that insanity hasn't resulted.
+        assert len(v) == len(w) == 4



More information about the Pypy-commit mailing list