File tree 2 files changed +17
-8
lines changed
2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -1427,8 +1427,6 @@ def test_find_etc_raise_correct_error_messages(self):
1427
1427
class MixinStrUnicodeTest :
1428
1428
# Additional tests that only work with str.
1429
1429
1430
- # TODO: RUSTPYTHON
1431
- @unittest .expectedFailure
1432
1430
def test_bug1001011 (self ):
1433
1431
# Make sure join returns a NEW object for single item sequences
1434
1432
# involving a subclass.
Original file line number Diff line number Diff line change @@ -860,13 +860,24 @@ impl PyStr {
860
860
}
861
861
862
862
#[ pymethod]
863
- fn join ( & self , iterable : ArgIterable < PyStrRef > , vm : & VirtualMachine ) -> PyResult < PyStrRef > {
863
+ fn join (
864
+ zelf : PyRef < Self > ,
865
+ iterable : ArgIterable < PyStrRef > ,
866
+ vm : & VirtualMachine ,
867
+ ) -> PyResult < PyStrRef > {
864
868
let iter = iterable. iter ( vm) ?;
865
-
866
- match iter. exactly_one ( ) {
867
- Ok ( first) => first,
868
- Err ( iter) => Ok ( vm. ctx . new_str ( self . as_str ( ) . py_join ( iter) ?) ) ,
869
- }
869
+ let joined = match iter. exactly_one ( ) {
870
+ Ok ( first) => {
871
+ let first = first?;
872
+ if first. as_object ( ) . class ( ) . is ( vm. ctx . types . str_type ) {
873
+ return Ok ( first) ;
874
+ } else {
875
+ first. as_str ( ) . to_owned ( )
876
+ }
877
+ }
878
+ Err ( iter) => zelf. as_str ( ) . py_join ( iter) ?,
879
+ } ;
880
+ Ok ( joined. into_pystr_ref ( vm) )
870
881
}
871
882
872
883
// FIXME: two traversals of str is expensive
You can’t perform that action at this time.
0 commit comments