equal
deleted
inserted
replaced
6 # GNU General Public License version 2 or any later version. |
6 # GNU General Public License version 2 or any later version. |
7 |
7 |
8 from __future__ import absolute_import |
8 from __future__ import absolute_import |
9 |
9 |
10 import array |
10 import array |
|
11 import io |
11 import locale |
12 import locale |
12 import os |
13 import os |
13 import unicodedata |
14 import unicodedata |
14 |
15 |
15 from . import ( |
16 from . import ( |
571 # unescape U+DCxx characters |
572 # unescape U+DCxx characters |
572 if "\xed\xb0\x80" <= c <= "\xed\xb3\xbf": |
573 if "\xed\xb0\x80" <= c <= "\xed\xb3\xbf": |
573 c = chr(ord(c.decode("utf-8")) & 0xff) |
574 c = chr(ord(c.decode("utf-8")) & 0xff) |
574 r += c |
575 r += c |
575 return r |
576 return r |
|
577 |
|
578 class strio(io.TextIOWrapper): |
|
579 """Wrapper around TextIOWrapper that respects hg's encoding assumptions. |
|
580 |
|
581 Also works around Python closing streams. |
|
582 """ |
|
583 |
|
584 def __init__(self, buffer, **kwargs): |
|
585 kwargs[r'encoding'] = _sysstr(encoding) |
|
586 super(strio, self).__init__(buffer, **kwargs) |
|
587 |
|
588 def __del__(self): |
|
589 """Override __del__ so it doesn't close the underlying stream.""" |