Show More
@@ -408,21 +408,21 b' if pycompat.iswindows:' | |||
|
408 | 408 | _INVALID_HANDLE_VALUE = -1 |
|
409 | 409 | |
|
410 | 410 | class _COORD(ctypes.Structure): |
|
411 | _fields_ = [('X', ctypes.c_short), | |
|
412 | ('Y', ctypes.c_short)] | |
|
411 | _fields_ = [(r'X', ctypes.c_short), | |
|
412 | (r'Y', ctypes.c_short)] | |
|
413 | 413 | |
|
414 | 414 | class _SMALL_RECT(ctypes.Structure): |
|
415 | _fields_ = [('Left', ctypes.c_short), | |
|
416 | ('Top', ctypes.c_short), | |
|
417 | ('Right', ctypes.c_short), | |
|
418 | ('Bottom', ctypes.c_short)] | |
|
415 | _fields_ = [(r'Left', ctypes.c_short), | |
|
416 | (r'Top', ctypes.c_short), | |
|
417 | (r'Right', ctypes.c_short), | |
|
418 | (r'Bottom', ctypes.c_short)] | |
|
419 | 419 | |
|
420 | 420 | class _CONSOLE_SCREEN_BUFFER_INFO(ctypes.Structure): |
|
421 | _fields_ = [('dwSize', _COORD), | |
|
422 | ('dwCursorPosition', _COORD), | |
|
423 | ('wAttributes', _WORD), | |
|
424 | ('srWindow', _SMALL_RECT), | |
|
425 | ('dwMaximumWindowSize', _COORD)] | |
|
421 | _fields_ = [(r'dwSize', _COORD), | |
|
422 | (r'dwCursorPosition', _COORD), | |
|
423 | (r'wAttributes', _WORD), | |
|
424 | (r'srWindow', _SMALL_RECT), | |
|
425 | (r'dwMaximumWindowSize', _COORD)] | |
|
426 | 426 | |
|
427 | 427 | _STD_OUTPUT_HANDLE = 0xfffffff5 # (DWORD)-11 |
|
428 | 428 | _STD_ERROR_HANDLE = 0xfffffff4 # (DWORD)-12 |
@@ -484,7 +484,7 b' if pycompat.iswindows:' | |||
|
484 | 484 | w32effects = None |
|
485 | 485 | else: |
|
486 | 486 | origattr = csbi.wAttributes |
|
487 | ansire = re.compile('\033\[([^m]*)m([^\033]*)(.*)', | |
|
487 | ansire = re.compile(b'\033\[([^m]*)m([^\033]*)(.*)', | |
|
488 | 488 | re.MULTILINE | re.DOTALL) |
|
489 | 489 | |
|
490 | 490 | def win32print(ui, writefunc, *msgs, **opts): |
@@ -516,15 +516,15 b' if pycompat.iswindows:' | |||
|
516 | 516 | # them if not found |
|
517 | 517 | pass |
|
518 | 518 | # hack to ensure regexp finds data |
|
519 | if not text.startswith('\033['): | |
|
520 | text = '\033[m' + text | |
|
519 | if not text.startswith(b'\033['): | |
|
520 | text = b'\033[m' + text | |
|
521 | 521 | |
|
522 | 522 | # Look for ANSI-like codes embedded in text |
|
523 | 523 | m = re.match(ansire, text) |
|
524 | 524 | |
|
525 | 525 | try: |
|
526 | 526 | while m: |
|
527 | for sattr in m.group(1).split(';'): | |
|
527 | for sattr in m.group(1).split(b';'): | |
|
528 | 528 | if sattr: |
|
529 | 529 | attr = mapcolor(int(sattr), attr) |
|
530 | 530 | ui.flush() |
@@ -14,6 +14,7 b' import socket' | |||
|
14 | 14 | import stat as statmod |
|
15 | 15 | |
|
16 | 16 | from .. import ( |
|
17 | encoding, | |
|
17 | 18 | pycompat, |
|
18 | 19 | ) |
|
19 | 20 | |
@@ -193,7 +194,8 b' else:' | |||
|
193 | 194 | |
|
194 | 195 | def _raiseioerror(name): |
|
195 | 196 | err = ctypes.WinError() |
|
196 |
raise IOError(err.errno, '%s: %s' % (name, |
|
|
197 | raise IOError(err.errno, r'%s: %s' % (encoding.strfromlocal(name), | |
|
198 | err.strerror)) | |
|
197 | 199 | |
|
198 | 200 | class posixfile(object): |
|
199 | 201 | '''a file object aiming for POSIX-like semantics |
@@ -207,14 +209,14 b' else:' | |||
|
207 | 209 | remains but cannot be opened again or be recreated under the same name, |
|
208 | 210 | until all reading processes have closed the file.''' |
|
209 | 211 | |
|
210 | def __init__(self, name, mode='r', bufsize=-1): | |
|
211 | if 'b' in mode: | |
|
212 | def __init__(self, name, mode=b'r', bufsize=-1): | |
|
213 | if b'b' in mode: | |
|
212 | 214 | flags = _O_BINARY |
|
213 | 215 | else: |
|
214 | 216 | flags = _O_TEXT |
|
215 | 217 | |
|
216 | m0 = mode[0] | |
|
217 | if m0 == 'r' and '+' not in mode: | |
|
218 | m0 = mode[0:1] | |
|
219 | if m0 == b'r' and b'+' not in mode: | |
|
218 | 220 | flags |= _O_RDONLY |
|
219 | 221 | access = _GENERIC_READ |
|
220 | 222 | else: |
@@ -223,15 +225,15 b' else:' | |||
|
223 | 225 | flags |= _O_RDWR |
|
224 | 226 | access = _GENERIC_READ | _GENERIC_WRITE |
|
225 | 227 | |
|
226 | if m0 == 'r': | |
|
228 | if m0 == b'r': | |
|
227 | 229 | creation = _OPEN_EXISTING |
|
228 | elif m0 == 'w': | |
|
230 | elif m0 == b'w': | |
|
229 | 231 | creation = _CREATE_ALWAYS |
|
230 | elif m0 == 'a': | |
|
232 | elif m0 == b'a': | |
|
231 | 233 | creation = _OPEN_ALWAYS |
|
232 | 234 | flags |= _O_APPEND |
|
233 | 235 | else: |
|
234 | raise ValueError("invalid mode: %s" % mode) | |
|
236 | raise ValueError(r"invalid mode: %s" % pycompat.sysstr(mode)) | |
|
235 | 237 | |
|
236 | 238 | fh = _kernel32.CreateFileA(name, access, |
|
237 | 239 | _FILE_SHARE_READ | _FILE_SHARE_WRITE | _FILE_SHARE_DELETE, |
@@ -389,7 +389,7 b' def shellquote(s):' | |||
|
389 | 389 | """ |
|
390 | 390 | global _quotere |
|
391 | 391 | if _quotere is None: |
|
392 | _quotere = re.compile(r'(\\*)("|\\$)') | |
|
392 | _quotere = re.compile(br'(\\*)("|\\$)') | |
|
393 | 393 | global _needsshellquote |
|
394 | 394 | if _needsshellquote is None: |
|
395 | 395 | # ":" is also treated as "safe character", because it is used as a part |
@@ -397,11 +397,11 b' def shellquote(s):' | |||
|
397 | 397 | # safe because shlex.split() (kind of) treats it as an escape char and |
|
398 | 398 | # drops it. It will leave the next character, even if it is another |
|
399 | 399 | # "\". |
|
400 | _needsshellquote = re.compile(r'[^a-zA-Z0-9._:/-]').search | |
|
400 | _needsshellquote = re.compile(br'[^a-zA-Z0-9._:/-]').search | |
|
401 | 401 | if s and not _needsshellquote(s) and not _quotere.search(s): |
|
402 | 402 | # "s" shouldn't have to be quoted |
|
403 | 403 | return s |
|
404 | return '"%s"' % _quotere.sub(r'\1\1\\\2', s) | |
|
404 | return b'"%s"' % _quotere.sub(br'\1\1\\\2', s) | |
|
405 | 405 | |
|
406 | 406 | def _unquote(s): |
|
407 | 407 | if s.startswith(b'"') and s.endswith(b'"'): |
General Comments 0
You need to be logged in to leave comments.
Login now