This repository was archived by the owner on Jan 3, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -502,16 +502,16 @@ def file_write(self, w_data):
502502the file on disk reflects the data written."""
503503 space = self .space
504504 self .check_writable ()
505+ if space .isinstance_w (w_data , space .w_unicode ):
506+ # note: "encode" is called before we acquire the lock
507+ # for this file, which is done in file_write_str().
508+ # Use a specific space method because we don't want
509+ # to call user-defined "encode" methods here.
510+ w_data = space .encode_unicode_object (w_data ,
511+ self .encoding , self .errors )
505512 if self .binary :
506513 data = space .getarg_w ('s*' , w_data ).as_str ()
507514 else :
508- if space .isinstance_w (w_data , space .w_unicode ):
509- # note: "encode" is called before we acquire the lock
510- # for this file, which is done in file_write_str().
511- # Use a specific space method because we don't want
512- # to call user-defined "encode" methods here.
513- w_data = space .encode_unicode_object (w_data ,
514- self .encoding , self .errors )
515515 data = space .charbuf_w (w_data )
516516 self .file_write_str (data )
517517
You can’t perform that action at this time.
0 commit comments