[pypy-svn] r35954 - in pypy/dist/pypy/objspace/std: . test
mwh at codespeak.net
mwh at codespeak.net
Fri Dec 22 14:49:11 CET 2006
Author: mwh
Date: Fri Dec 22 14:49:08 2006
New Revision: 35954
Modified:
pypy/dist/pypy/objspace/std/strjoinobject.py
pypy/dist/pypy/objspace/std/test/test_strjoinobject.py
Log:
fix more bugs in strjoins
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 14:49:08 2006
@@ -13,8 +13,8 @@
until = len(joined_strs)
w_self.until = until
- def force(w_self):
- if w_self.until == 1:
+ def force(w_self, always=False):
+ if w_self.until == 1 and not always:
return w_self.joined_strs[0]
res = "".join(w_self.joined_strs[:w_self.until])
w_self.joined_strs = [res]
@@ -49,13 +49,13 @@
def add__StringJoin_StringJoin(space, w_self, w_other):
if len(w_self.joined_strs) > w_self.until:
- w_self.force()
+ w_self.force(True)
w_self.joined_strs.extend(w_other.joined_strs)
return W_StringJoinObject(w_self.joined_strs)
def add__StringJoin_String(space, w_self, w_other):
if len(w_self.joined_strs) > w_self.until:
- w_self.force()
+ w_self.force(True)
other = space.str_w(w_other)
w_self.joined_strs.append(other)
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 14:49:08 2006
@@ -55,3 +55,10 @@
# check that insanity hasn't resulted.
assert len(v) == len(w) == 4
+
+ def test_more_adding_fun(self):
+ s = 'a' + 'b' # s is a strjoin now
+ t = s + 'c' # this calls s.force() which sets s.until to 1
+ u = s + 'd'
+ v = s + 'e'
+ assert v == 'abe' # meaning u is abcd
More information about the Pypy-commit
mailing list