Mercurial > public > mercurial-scm > hg
diff mercurial/encoding.py @ 33852: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 |
line wrap: on
line diff
--- a/mercurial/encoding.py Sun Aug 13 14:12:28 2017 +0900 +++ b/mercurial/encoding.py Wed Aug 16 13:50:11 2017 +0900 @@ -575,15 +575,17 @@ r += c return r -class strio(io.TextIOWrapper): - """Wrapper around TextIOWrapper that respects hg's encoding assumptions. +if pycompat.ispy3: + class strio(io.TextIOWrapper): + """Wrapper around TextIOWrapper that respects hg's encoding assumptions. - Also works around Python closing streams. - """ + Also works around Python closing streams. + """ - def __init__(self, buffer, **kwargs): - kwargs[r'encoding'] = _sysstr(encoding) - super(strio, self).__init__(buffer, **kwargs) + def __init__(self, buffer): + super(strio, self).__init__(buffer, encoding=_sysstr(encoding)) - def __del__(self): - """Override __del__ so it doesn't close the underlying stream.""" + def __del__(self): + """Override __del__ so it doesn't close the underlying stream.""" +else: + strio = pycompat.identity