[pypy-svn] r48145 - in pypy/dist/pypy/lang/smalltalk: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Mon Oct 29 12:11:51 CET 2007


Author: cfbolz
Date: Mon Oct 29 12:11:51 2007
New Revision: 48145

Modified:
   pypy/dist/pypy/lang/smalltalk/model.py
   pypy/dist/pypy/lang/smalltalk/test/test_model.py
Log:
python strings are _not_ mutable. Of course there never was a test, 
so nobody noticed this nonsense. Have I noticed that I am grumpy?


Modified: pypy/dist/pypy/lang/smalltalk/model.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/model.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/model.py	Mon Oct 29 12:11:51 2007
@@ -368,8 +368,9 @@
         else:
             self.setbyte(index0, chr(unwrap_int(w_value)))
 
-    def setbyte(self, index0, chr):
-        self.bytes[index0] = chr
+    def setbyte(self, index0, character):
+        self.bytes = (self.bytes[:index0] + character +
+                      self.bytes[index0 + 1:])
 
 class W_ContextPart(W_AbstractObjectWithIdentityHash):
 

Modified: pypy/dist/pypy/lang/smalltalk/test/test_model.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/test/test_model.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/test/test_model.py	Mon Oct 29 12:11:51 2007
@@ -70,6 +70,11 @@
     classshadow = w_class.as_class_get_shadow()
     assert classshadow.lookup("foo").w_compiledin is w_super
 
+def test_w_compiledin():
+    w_method = model.W_CompiledMethod(0, "abc")
+    w_method.setbyte(0, "c")
+    assert w_method.bytes == "cbc"
+
 def test_hashes():
     w_five = model.W_SmallInteger(5)
     assert w_five.gethash() == 5



More information about the Pypy-commit mailing list