# HG changeset patch # User Yuya Nishihara # Date 1539669977 -7200 # Node ID 6958eb9bdcd6cb90639880ae6274ac5353031e79 # Parent 09540a5f0a15d91ae97f4db1e84288dd1af2e959 py3: rewrite StringIO fallback for Python 3 diff -r 09540a5f0a15 -r 6958eb9bdcd6 contrib/hgclient.py --- a/contrib/hgclient.py Tue Oct 16 07:04:07 2018 +0200 +++ b/contrib/hgclient.py Tue Oct 16 08:06:17 2018 +0200 @@ -1,6 +1,8 @@ # A minimal client for Mercurial's command server from __future__ import absolute_import, print_function + +import io import os import re import signal @@ -10,23 +12,19 @@ import sys import time -try: - import cStringIO as io - stringio = io.StringIO -except ImportError: - import io - stringio = io.StringIO - if sys.version_info[0] >= 3: stdout = sys.stdout.buffer stderr = sys.stderr.buffer + stringio = io.BytesIO def bprint(*args): # remove b'' as well for ease of test migration pargs = [re.sub(br'''\bb(['"])''', br'\1', b'%s' % a) for a in args] stdout.write(b' '.join(pargs) + b'\n') else: + import cStringIO stdout = sys.stdout stderr = sys.stderr + stringio = cStringIO.StringIO bprint = print def connectpipe(path=None):