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 @@ -876,13 +876,24 @@ impl PyStr {
876876 }
877877
878878 #[ pymethod]
879- fn join ( & self , iterable : ArgIterable < PyStrRef > , vm : & VirtualMachine ) -> PyResult < PyStrRef > {
879+ fn join (
880+ zelf : PyRef < Self > ,
881+ iterable : ArgIterable < PyStrRef > ,
882+ vm : & VirtualMachine ,
883+ ) -> PyResult < PyStrRef > {
880884 let iter = iterable. iter ( vm) ?;
881-
882- match iter. exactly_one ( ) {
883- Ok ( first) => first,
884- Err ( iter) => Ok ( vm. ctx . new_str ( self . as_str ( ) . py_join ( iter) ?) ) ,
885- }
885+ let joined = match iter. exactly_one ( ) {
886+ Ok ( first) => {
887+ let first = first?;
888+ if first. as_object ( ) . class ( ) . is ( vm. ctx . types . str_type ) {
889+ return Ok ( first) ;
890+ } else {
891+ first. as_str ( ) . to_owned ( )
892+ }
893+ }
894+ Err ( iter) => zelf. as_str ( ) . py_join ( iter) ?,
895+ } ;
896+ Ok ( joined. into_pystr_ref ( vm) )
886897 }
887898
888899 // FIXME: two traversals of str is expensive
You can’t perform that action at this time.
0 commit comments