Skip to content

Commit efa5026

Browse files
committed
in rsplit with a String separator, split *after* the separator
1 parent 9b4544a commit efa5026

File tree

1 file changed

+2
-1
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str

1 file changed

+2
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1203,14 +1203,15 @@ public PList doSplit(String self, String sep, int maxsplit) {
12031203
int splits = 0;
12041204
int end = self.length();
12051205
String remainder = self;
1206+
int sepLength = Math.max(1, sep.length());
12061207
while (splits < maxsplit) {
12071208
int idx = remainder.lastIndexOf(sep);
12081209

12091210
if (idx < 0) {
12101211
break;
12111212
}
12121213

1213-
getAppendNode().execute(list, self.substring(idx + 1, end));
1214+
getAppendNode().execute(list, self.substring(idx + sepLength, end));
12141215
end = idx;
12151216
splits++;
12161217
remainder = remainder.substring(0, end);

0 commit comments

Comments
 (0)