[pypy-commit] pypy default: add comment
gutworth
noreply at buildbot.pypy.org
Thu Mar 29 14:47:49 CEST 2012
Author: Benjamin Peterson <benjamin at python.org>
Branch:
Changeset: r54061:49edece70bd7
Date: 2012-03-29 08:43 -0400
http://bitbucket.org/pypy/pypy/changeset/49edece70bd7/
Log: add comment
diff --git a/pypy/rpython/lltypesystem/rstr.py b/pypy/rpython/lltypesystem/rstr.py
--- a/pypy/rpython/lltypesystem/rstr.py
+++ b/pypy/rpython/lltypesystem/rstr.py
@@ -765,6 +765,8 @@
def _ll_stringslice(s1, start, stop):
lgt = stop - start
assert start >= 0
+ # If start >= stop, return a empty string. This can happen if the start
+ # is greater than the length of the string.
if lgt <= 0:
return s1.empty()
newstr = s1.malloc(lgt)
diff --git a/pypy/rpython/ootypesystem/rstr.py b/pypy/rpython/ootypesystem/rstr.py
--- a/pypy/rpython/ootypesystem/rstr.py
+++ b/pypy/rpython/ootypesystem/rstr.py
@@ -222,6 +222,8 @@
length = s.ll_strlen()
if stop > length:
stop = length
+ # If start > stop, return a empty string. This can happen if the start
+ # is greater than the length of the string.
if start > stop:
start = stop
return s.ll_substring(start, stop-start)
More information about the pypy-commit
mailing list