mercurial/pycompat.py
author timeless <timeless@mozdev.org>
Wed, 06 Apr 2016 20:31:31 +0000
changeset 28835 68a946e83188
parent 28834 2fac032c1269
child 28882 800ec7c048b0
permissions -rw-r--r--
pycompat: add util.stringio to handle py3 divergence util.stringio = cStringIO.StringIO / io.StringIO

# pycompat.py - portability shim for python 3
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.

"""Mercurial portability shim for python 3.

This contains aliases to hide python version-specific details from the core.
"""

from __future__ import absolute_import

try:
    import cStringIO as io
    stringio = io.StringIO
except ImportError:
    import io
    stringio = io.StringIO

try:
    import Queue as _queue
    _queue.Queue
except ImportError:
    import queue as _queue
empty = _queue.Empty
queue = _queue.Queue

try:
    xrange
except NameError:
    import builtins
    builtins.xrange = range