Commits

Brian Kearns committed 2db1e1e

(amaury) presize to maxsplit + 1 not maxsplit

  • Participants
  • Parent commits 2924a59

Comments (0)

Files changed (1)

File rpython/rlib/rstring.py

         raise ValueError("empty separator")
 
     if maxsplit > 0:
-        res = newlist_hint(min(maxsplit, len(value)))
+        res = newlist_hint(min(maxsplit + 1, len(value)))
     else:
         res = []
     start = 0
 
 def rsplit(value, by, maxsplit=-1):
     if maxsplit > 0:
-        res = newlist_hint(min(maxsplit, len(value)))
+        res = newlist_hint(min(maxsplit + 1, len(value)))
     else:
         res = []
     end = len(value)