[pypy-svn] r59113 - in pypy/trunk/pypy/objspace/std: . test

arigo at codespeak.net arigo at codespeak.net
Wed Oct 15 18:12:03 CEST 2008


Author: arigo
Date: Wed Oct 15 18:12:03 2008
New Revision: 59113

Modified:
   pypy/trunk/pypy/objspace/std/ropeunicodeobject.py
   pypy/trunk/pypy/objspace/std/stringobject.py
   pypy/trunk/pypy/objspace/std/test/test_stringobject.py
Log:
(cfbolz, arigo)
Fix a failing test.  Add another failing test and skip it for now.


Modified: pypy/trunk/pypy/objspace/std/ropeunicodeobject.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/ropeunicodeobject.py	(original)
+++ pypy/trunk/pypy/objspace/std/ropeunicodeobject.py	Wed Oct 15 18:12:03 2008
@@ -722,7 +722,11 @@
     oldlength = old.length()
     if not oldlength:
         parts = _split_into_chars(self, maxsplit)
-        return W_RopeUnicodeObject(rope.join(w_new._node, parts))
+        try:
+            return W_RopeUnicodeObject(rope.join(w_new._node, parts))
+        except OverflowError:
+            raise OperationError(space.w_OverflowError,
+                                 space.wrap("string too long"))
     substrings = rope.split(self, old, maxsplit)
     if not substrings:
         return w_self.create_if_subclassed()
@@ -790,7 +794,11 @@
                                       _tabindent(last, tabsize)))
         last = splitted[i]
         expanded.append(last)
-    return W_RopeUnicodeObject(rope.rebalance(expanded))
+    try:
+        return W_RopeUnicodeObject(rope.rebalance(expanded))
+    except OverflowError:
+        raise OperationError(space.w_OverflowError,
+                             space.wrap("string too long"))
 
 def unicode_translate__RopeUnicode_ANY(space, w_self, w_table):
     self = w_self._node

Modified: pypy/trunk/pypy/objspace/std/stringobject.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/stringobject.py	(original)
+++ pypy/trunk/pypy/objspace/std/stringobject.py	Wed Oct 15 18:12:03 2008
@@ -665,7 +665,7 @@
     
     u_expanded = ""
     if u_self:
-        split = u_self.split("\t") #XXX use pypy split
+        split = u_self.split("\t")
         u_expanded =oldtoken = split.pop(0)
 
         for token in split:  

Modified: pypy/trunk/pypy/objspace/std/test/test_stringobject.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/test/test_stringobject.py	(original)
+++ pypy/trunk/pypy/objspace/std/test/test_stringobject.py	Wed Oct 15 18:12:03 2008
@@ -396,6 +396,12 @@
         assert 'xy'.expandtabs() =='xy'
         assert ''.expandtabs() ==''
 
+    def test_expandtabs_overflows_gracefully(self):
+        skip("XXX fix me")
+        import sys
+        if sys.maxint > (1 << 32):
+            skip("Wrong platform")
+        raises(OverflowError, 't\tt\t'.expandtabs, sys.maxint)
 
     def test_splitlines(self):
         s = ""



More information about the Pypy-commit mailing list