Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/encoding.py @ 33873:f18b11534274
py3: make encoding.strio() an identity function on Python 2
It's the convention the other encoding.str*() functions follow. To make things
simple, this also drops kwargs from the strio() constructor.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 16 Aug 2017 13:50:11 +0900 |
parents | 7d5bc0e5b88f |
children | b9101467d88b |
comparison
equal
deleted
inserted
replaced
33872:7827fbbd0b06 | 33873:f18b11534274 |
---|---|
573 if "\xed\xb0\x80" <= c <= "\xed\xb3\xbf": | 573 if "\xed\xb0\x80" <= c <= "\xed\xb3\xbf": |
574 c = chr(ord(c.decode("utf-8")) & 0xff) | 574 c = chr(ord(c.decode("utf-8")) & 0xff) |
575 r += c | 575 r += c |
576 return r | 576 return r |
577 | 577 |
578 class strio(io.TextIOWrapper): | 578 if pycompat.ispy3: |
579 """Wrapper around TextIOWrapper that respects hg's encoding assumptions. | 579 class strio(io.TextIOWrapper): |
580 | 580 """Wrapper around TextIOWrapper that respects hg's encoding assumptions. |
581 Also works around Python closing streams. | 581 |
582 """ | 582 Also works around Python closing streams. |
583 | 583 """ |
584 def __init__(self, buffer, **kwargs): | 584 |
585 kwargs[r'encoding'] = _sysstr(encoding) | 585 def __init__(self, buffer): |
586 super(strio, self).__init__(buffer, **kwargs) | 586 super(strio, self).__init__(buffer, encoding=_sysstr(encoding)) |
587 | 587 |
588 def __del__(self): | 588 def __del__(self): |
589 """Override __del__ so it doesn't close the underlying stream.""" | 589 """Override __del__ so it doesn't close the underlying stream.""" |
590 else: | |
591 strio = pycompat.identity |