##// END OF EJS Templates
encoding: use raw strings for encoding arguments...
Gregory Szorc -
r42002:25694a78 default
parent child Browse files
Show More
@@ -65,7 +65,7 b' elif _nativeenviron:'
65 65 else:
66 66 # preferred encoding isn't known yet; use utf-8 to avoid unicode error
67 67 # and recreate it once encoding is settled
68 environ = dict((k.encode(u'utf-8'), v.encode(u'utf-8'))
68 environ = dict((k.encode(r'utf-8'), v.encode(r'utf-8'))
69 69 for k, v in os.environ.items()) # re-exports
70 70
71 71 _encodingrewrites = {
@@ -152,7 +152,7 b' def tolocal(s):'
152 152 if encoding == 'UTF-8':
153 153 # fast path
154 154 return s
155 r = u.encode(_sysstr(encoding), u"replace")
155 r = u.encode(_sysstr(encoding), r"replace")
156 156 if u == r.decode(_sysstr(encoding)):
157 157 # r is a safe, non-lossy encoding of s
158 158 return safelocalstr(r)
@@ -161,7 +161,7 b' def tolocal(s):'
161 161 # we should only get here if we're looking at an ancient changeset
162 162 try:
163 163 u = s.decode(_sysstr(fallbackencoding))
164 r = u.encode(_sysstr(encoding), u"replace")
164 r = u.encode(_sysstr(encoding), r"replace")
165 165 if u == r.decode(_sysstr(encoding)):
166 166 # r is a safe, non-lossy encoding of s
167 167 return safelocalstr(r)
@@ -169,7 +169,7 b' def tolocal(s):'
169 169 except UnicodeDecodeError:
170 170 u = s.decode("utf-8", "replace") # last ditch
171 171 # can't round-trip
172 return u.encode(_sysstr(encoding), u"replace")
172 return u.encode(_sysstr(encoding), r"replace")
173 173 except LookupError as k:
174 174 raise error.Abort(k, hint="please check your locale settings")
175 175
@@ -230,7 +230,7 b' else:'
230 230 if not _nativeenviron:
231 231 # now encoding and helper functions are available, recreate the environ
232 232 # dict to be exported to other modules
233 environ = dict((tolocal(k.encode(u'utf-8')), tolocal(v.encode(u'utf-8')))
233 environ = dict((tolocal(k.encode(r'utf-8')), tolocal(v.encode(r'utf-8')))
234 234 for k, v in os.environ.items()) # re-exports
235 235
236 236 if pycompat.ispy3:
@@ -251,7 +251,7 b' else:'
251 251
252 252 def colwidth(s):
253 253 "Find the column width of a string for display in the local encoding"
254 return ucolwidth(s.decode(_sysstr(encoding), u'replace'))
254 return ucolwidth(s.decode(_sysstr(encoding), r'replace'))
255 255
256 256 def ucolwidth(d):
257 257 "Find the column width of a Unicode string for display"
General Comments 0
You need to be logged in to leave comments. Login now