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

arigo at codespeak.net arigo at codespeak.net
Sun May 15 19:02:09 CEST 2005


Author: arigo
Date: Sun May 15 19:02:09 2005
New Revision: 12314

Modified:
   pypy/dist/pypy/objspace/std/stringobject.py
   pypy/dist/pypy/objspace/std/test/test_stringobject.py
Log:
str.split('') should raise ValueError instead of trying to build an infinite
list of empty strings...


Modified: pypy/dist/pypy/objspace/std/stringobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/stringobject.py	(original)
+++ pypy/dist/pypy/objspace/std/stringobject.py	Sun May 15 19:02:09 2005
@@ -263,6 +263,8 @@
     value = w_self._value
     by = w_by._value
     bylen = len(by)
+    if bylen == 0:
+        raise OperationError(space.w_ValueError, space.wrap("empty separator"))
     maxsplit = space.int_w(w_maxsplit)
 
     #if maxsplit is default, then you have no limit

Modified: pypy/dist/pypy/objspace/std/test/test_stringobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_stringobject.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_stringobject.py	Sun May 15 19:02:09 2005
@@ -140,6 +140,7 @@
         assert 'a b c d '.split() == ['a', 'b', 'c', 'd']
         assert 'a//b//c//d'.split('//') == ['a', 'b', 'c', 'd']
         assert 'endcase test'.split('test') == ['endcase ', '']
+        raises(ValueError, 'abc'.split, '')
 
     def test_split_splitchar(self):
         assert "/a/b/c".split('/') == ['','a','b','c']



More information about the Pypy-commit mailing list