Skip to content

Commit d84b8b5

Browse files
committed
Fix the tuple from rpartition being in wrong order when sub isn't
contained within the string
1 parent 1081ea0 commit d84b8b5

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

tests/snippets/strings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@
132132
assert '-'.join(['1', '2', '3']) == '1-2-3'
133133
assert 'HALLO'.isupper()
134134
assert "hello, my name is".partition("my ") == ('hello, ', 'my ', 'name is')
135+
assert "hello".partition("is") == ('hello', '', '')
135136
assert "hello, my name is".rpartition("is") == ('hello, my name ', 'is', '')
137+
assert "hello".rpartition("is") == ('', '', 'hello')
136138
assert not ''.isdecimal()
137139
assert '123'.isdecimal()
138140
assert not '\u00B2'.isdecimal()

vm/src/obj/objstr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,9 +635,9 @@ impl PyString {
635635
new_tup.swap(0, 1); // so it's in the right order
636636
new_tup.insert(1, vm.ctx.new_str(sub.clone()));
637637
} else {
638-
new_tup.push(vm.ctx.new_str(value.clone()));
639638
new_tup.push(vm.ctx.new_str("".to_string()));
640639
new_tup.push(vm.ctx.new_str("".to_string()));
640+
new_tup.push(vm.ctx.new_str(value.clone()));
641641
}
642642
vm.ctx.new_tuple(new_tup)
643643
}

0 commit comments

Comments
 (0)