Patchwork [8,of,8] py3: drop encoding.strio()

login
register
mail settings
Submitter Yuya Nishihara
Date March 9, 2018, 12:35 p.m.
Message ID <168badbb03b574d2a77a.1520598941@mimosa>
Download mbox | patch
Permalink /patch/29168/
State Accepted
Headers show

Comments

Yuya Nishihara - March 9, 2018, 12:35 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1520325797 21600
#      Tue Mar 06 02:43:17 2018 -0600
# Node ID 168badbb03b574d2a77ae503d3b77709c68e0537
# Parent  5ee522c20bc23701248014fa18e90f691f00aec8
py3: drop encoding.strio()

Its buffered nature makes TextIOWrapper unsuitable for temporarily wrapping
bytes I/O.

Patch

diff --git a/mercurial/encoding.py b/mercurial/encoding.py
--- a/mercurial/encoding.py
+++ b/mercurial/encoding.py
@@ -7,7 +7,6 @@ 
 
 from __future__ import absolute_import, print_function
 
-import io
 import locale
 import os
 import unicodedata
@@ -581,18 +580,3 @@  def fromutf8b(s):
             c = pycompat.bytechr(ord(c.decode("utf-8", _utf8strict)) & 0xff)
         r += c
     return r
-
-if pycompat.ispy3:
-    class strio(io.TextIOWrapper):
-        """Wrapper around TextIOWrapper that respects hg's encoding assumptions.
-
-        Also works around Python closing streams.
-        """
-
-        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."""
-else:
-    strio = pycompat.identity