@@ -67,20 +67,21 @@ constants.""")
67
67
68
68
if args .enable_windows_compatibility :
69
69
if args .enable_yaml_compatibility :
70
- slashes_re = b '(/|\\ \\ \\ \\ | \\ \\ \\ \\ \\ \\ \\ \\ )'
70
+ slashes_re = r '(/|\\\\| \\\\\\\\)'
71
71
else :
72
- slashes_re = b '(/|\\ \\ \\ \\ )'
72
+ slashes_re = r '(/|\\\\)'
73
73
else :
74
- slashes_re = b '/'
74
+ slashes_re = r '/'
75
75
76
- stdin = io .open (sys .stdin .fileno (), 'rb ' ).read ()
76
+ stdin = io .open (sys .stdin .fileno (), 'r' , encoding = 'utf-8' , errors = 'ignore ' ).read ()
77
77
78
78
for s in args .sanitize_strings :
79
- replacement , pattern = s .encode ( encoding = "utf-8" ). split (b '=' , 1 )
79
+ replacement , pattern = s .split ('=' , 1 )
80
80
# Since we want to use pattern as a regex in some platforms, we need
81
81
# to escape it first, and then replace the escaped slash
82
82
# 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 )),
84
85
replacement ,
85
86
stdin )
86
87
@@ -90,7 +91,7 @@ constants.""")
90
91
else :
91
92
p = subprocess .Popen (
92
93
[args .file_check_path ] + unknown_args , stdin = subprocess .PIPE )
93
- stdout , stderr = p .communicate (stdin )
94
+ stdout , stderr = p .communicate (stdin . encode ( 'utf-8' ) )
94
95
if stdout is not None :
95
96
print (stdout )
96
97
if stderr is not None :
0 commit comments