File tree Expand file tree Collapse file tree 2 files changed +17
-8
lines changed
Expand file tree Collapse file tree 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):
14271427class MixinStrUnicodeTest :
14281428 # Additional tests that only work with str.
14291429
1430- # TODO: RUSTPYTHON
1431- @unittest .expectedFailure
14321430 def test_bug1001011 (self ):
14331431 # Make sure join returns a NEW object for single item sequences
14341432 # involving a subclass.
Original file line number Diff line number Diff line change @@ -860,13 +860,24 @@ impl PyStr {
860860 }
861861
862862 #[ 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 > {
864868 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) )
870881 }
871882
872883 // FIXME: two traversals of str is expensive
You can’t perform that action at this time.
0 commit comments