@@ -67,20 +67,21 @@ constants.""")
6767
6868 if args .enable_windows_compatibility :
6969 if args .enable_yaml_compatibility :
70- slashes_re = b '(/|\\ \\ \\ \\ | \\ \\ \\ \\ \\ \\ \\ \\ )'
70+ slashes_re = r '(/|\\\\| \\\\\\\\)'
7171 else :
72- slashes_re = b '(/|\\ \\ \\ \\ )'
72+ slashes_re = r '(/|\\\\)'
7373 else :
74- slashes_re = b '/'
74+ slashes_re = r '/'
7575
76- stdin = io .open (sys .stdin .fileno (), 'rb ' ).read ()
76+ stdin = io .open (sys .stdin .fileno (), 'r' , encoding = 'utf-8' , errors = 'ignore ' ).read ()
7777
7878 for s in args .sanitize_strings :
79- replacement , pattern = s .encode ( encoding = "utf-8" ). split (b '=' , 1 )
79+ replacement , pattern = s .split ('=' , 1 )
8080 # Since we want to use pattern as a regex in some platforms, we need
8181 # to escape it first, and then replace the escaped slash
8282 # literal (r'\\/') for our platform-dependent slash regex.
83- stdin = re .sub (re .sub (b'\\ \\ /' , slashes_re , re .escape (pattern )),
83+ stdin = re .sub (re .sub ('\\ \\ /' if sys .version_info [0 ] < 3 else r'[/\\]' ,
84+ slashes_re , re .escape (pattern )),
8485 replacement ,
8586 stdin )
8687
@@ -90,7 +91,7 @@ constants.""")
9091 else :
9192 p = subprocess .Popen (
9293 [args .file_check_path ] + unknown_args , stdin = subprocess .PIPE )
93- stdout , stderr = p .communicate (stdin )
94+ stdout , stderr = p .communicate (stdin . encode ( 'utf-8' ) )
9495 if stdout is not None :
9596 print (stdout )
9697 if stderr is not None :
0 commit comments