##// END OF EJS Templates
win32mbcs: unbyteify some strings for py3 support...
Matt Harbison -
r51635:48d9af6b stable
parent child Browse files
Show More
@@ -82,7 +82,7 b' def decode(arg):'
82 82 uarg = arg.decode(_encoding)
83 83 if arg == uarg.encode(_encoding):
84 84 return uarg
85 raise UnicodeError(b"Not local encoding")
85 raise UnicodeError("Not local encoding")
86 86 elif isinstance(arg, tuple):
87 87 return tuple(map(decode, arg))
88 88 elif isinstance(arg, list):
@@ -111,8 +111,8 b' def appendsep(s):'
111 111 try:
112 112 us = decode(s)
113 113 except UnicodeError:
114 us = s
115 if us and us[-1] not in b':/\\':
114 us = s # TODO: how to handle this bytes case??
115 if us and us[-1] not in ':/\\':
116 116 s += pycompat.ossep
117 117 return s
118 118
@@ -148,13 +148,13 b' def wrapperforlistdir(func, args, kwds):'
148 148 if args:
149 149 args = list(args)
150 150 args[0] = appendsep(args[0])
151 if b'path' in kwds:
152 kwds[b'path'] = appendsep(kwds[b'path'])
151 if 'path' in kwds:
152 kwds['path'] = appendsep(kwds['path'])
153 153 return func(*args, **kwds)
154 154
155 155
156 def wrapname(name, wrapper):
157 module, name = name.rsplit(b'.', 1)
156 def wrapname(name: str, wrapper):
157 module, name = name.rsplit('.', 1)
158 158 module = sys.modules[module]
159 159 func = getattr(module, name)
160 160
@@ -168,7 +168,7 b' def wrapname(name, wrapper):'
168 168 # List of functions to be wrapped.
169 169 # NOTE: os.path.dirname() and os.path.basename() are safe because
170 170 # they use result of os.path.split()
171 funcs = b'''os.path.join os.path.split os.path.splitext
171 funcs = '''os.path.join os.path.split os.path.splitext
172 172 os.path.normpath os.makedirs mercurial.util.endswithsep
173 173 mercurial.util.splitpath mercurial.util.fscasesensitive
174 174 mercurial.util.fspath mercurial.util.pconvert mercurial.util.normpath
@@ -178,11 +178,11 b" funcs = b'''os.path.join os.path.split o"
178 178 # These functions are required to be called with local encoded string
179 179 # because they expects argument is local encoded string and cause
180 180 # problem with unicode string.
181 rfuncs = b'''mercurial.encoding.upper mercurial.encoding.lower
181 rfuncs = '''mercurial.encoding.upper mercurial.encoding.lower
182 182 mercurial.util._filenamebytestr'''
183 183
184 184 # List of Windows specific functions to be wrapped.
185 winfuncs = b'''os.path.splitunc'''
185 winfuncs = '''os.path.splitunc'''
186 186
187 187 # codec and alias names of sjis and big5 to be faked.
188 188 problematic_encodings = b'''big5 big5-tw csbig5 big5hkscs big5-hkscs
@@ -208,15 +208,15 b' def extsetup(ui):'
208 208 if pycompat.iswindows:
209 209 for f in winfuncs.split():
210 210 wrapname(f, wrapper)
211 wrapname(b"mercurial.util.listdir", wrapperforlistdir)
212 wrapname(b"mercurial.windows.listdir", wrapperforlistdir)
211 wrapname("mercurial.util.listdir", wrapperforlistdir)
212 wrapname("mercurial.windows.listdir", wrapperforlistdir)
213 213 # wrap functions to be called with local byte string arguments
214 214 for f in rfuncs.split():
215 215 wrapname(f, reversewrapper)
216 216 # Check sys.args manually instead of using ui.debug() because
217 217 # command line options is not yet applied when
218 218 # extensions.loadall() is called.
219 if b'--debug' in sys.argv:
219 if '--debug' in sys.argv:
220 220 ui.writenoi18n(
221 221 b"[win32mbcs] activated with encoding: %s\n" % _encoding
222 222 )
General Comments 0
You need to be logged in to leave comments. Login now