diff --git a/hgext/phabricator.py b/hgext/phabricator.py --- a/hgext/phabricator.py +++ b/hgext/phabricator.py @@ -62,6 +62,7 @@ import base64 import contextlib import hashlib +import io import itertools import json import mimetypes @@ -2200,7 +2201,7 @@ for drev, contents in patches: ui.status(_(b'applying patch from D%s\n') % drev) - with patch.extract(ui, pycompat.bytesio(contents)) as patchdata: + with patch.extract(ui, io.BytesIO(contents)) as patchdata: msg, node, rej = cmdutil.tryimportone( ui, repo, diff --git a/mercurial/pure/mpatch.py b/mercurial/pure/mpatch.py --- a/mercurial/pure/mpatch.py +++ b/mercurial/pure/mpatch.py @@ -7,11 +7,11 @@ from __future__ import absolute_import +import io import struct -from .. import pycompat -stringio = pycompat.bytesio +stringio = io.BytesIO class mpatchError(Exception): diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py --- a/mercurial/pure/parsers.py +++ b/mercurial/pure/parsers.py @@ -7,6 +7,7 @@ from __future__ import absolute_import +import io import stat import struct import zlib @@ -26,7 +27,7 @@ from ..revlogutils import nodemap as nodemaputil from ..revlogutils import constants as revlog_constants -stringio = pycompat.bytesio +stringio = io.BytesIO _pack = struct.pack diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py --- a/mercurial/pycompat.py +++ b/mercurial/pycompat.py @@ -111,9 +111,6 @@ sysexecutable = sys.executable if sysexecutable: sysexecutable = os.fsencode(sysexecutable) -bytesio = io.BytesIO -# TODO deprecate stringio name, as it is a lie on Python 3. -stringio = bytesio def maplist(*args): diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -21,6 +21,7 @@ import errno import gc import hashlib +import io import itertools import locale import mmap @@ -78,7 +79,7 @@ httplib = pycompat.httplib safehasattr = pycompat.safehasattr socketserver = pycompat.socketserver -bytesio = pycompat.bytesio +bytesio = io.BytesIO # TODO deprecate stringio name, as it is a lie on Python 3. stringio = bytesio xmlrpclib = pycompat.xmlrpclib diff --git a/tests/test-basic.t b/tests/test-basic.t --- a/tests/test-basic.t +++ b/tests/test-basic.t @@ -240,15 +240,16 @@ Underlying message streams should be updated when ui.fout/ferr are set: $ cat <<'EOF' > capui.py - > from mercurial import pycompat, registrar + > import io + > from mercurial import registrar > cmdtable = {} > command = registrar.command(cmdtable) > @command(b'capui', norepo=True) > def capui(ui): > out = ui.fout - > ui.fout = pycompat.bytesio() + > ui.fout = io.BytesIO() > ui.status(b'status\n') - > ui.ferr = pycompat.bytesio() + > ui.ferr = io.BytesIO() > ui.warn(b'warn\n') > out.write(b'stdout: %s' % ui.fout.getvalue()) > out.write(b'stderr: %s' % ui.ferr.getvalue()) diff --git a/tests/test-util.py b/tests/test-util.py --- a/tests/test-util.py +++ b/tests/test-util.py @@ -2,6 +2,7 @@ from __future__ import absolute_import import contextlib +import io import itertools import unittest @@ -55,7 +56,7 @@ @contextlib.contextmanager def capturestderr(): - """Replace utils.procutil.stderr with a pycompat.bytesio instance + """Replace utils.procutil.stderr with an io.BytesIO instance The instance is made available as the return value of __enter__. @@ -63,7 +64,7 @@ """ orig = utils.procutil.stderr - utils.procutil.stderr = pycompat.bytesio() + utils.procutil.stderr = io.BytesIO() try: yield utils.procutil.stderr finally: