Patchwork [4,of,7] pycompat: add util.stringio to handle py3 divergence

login
register
mail settings
Submitter timeless@mozdev.org
Date April 6, 2016, 9:57 p.m.
Message ID <fe05b5e676098d90810e.1459979861@waste.org>
Download mbox | patch
Permalink /patch/14404/
State Superseded
Commit 68a946e8318894bd95d0a5b3726006bb61fda6ad
Headers show

Comments

timeless@mozdev.org - April 6, 2016, 9:57 p.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1459974691 0
#      Wed Apr 06 20:31:31 2016 +0000
# Node ID fe05b5e676098d90810e3dc87126e1451ccc1ccb
# Parent  bcdf9805314cdeeb236acfb55f080f22fcad603a
pycompat: add util.stringio to handle py3 divergence

util.stringio = cStringIO.StringIO / io.StringIO

Patch

diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -11,6 +11,12 @@ 
 from __future__ import absolute_import
 
 try:
+    import cStringIO as io
+except ImportError:
+    import io
+stringio = io.StringIO
+
+try:
     import Queue as _queue
 except ImportError:
     import queue as _queue
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -49,6 +49,7 @@ 
 for attr in (
     'empty',
     'queue',
+    'stringio',
 ):
     globals()[attr] = getattr(pycompat, attr)