pycompat.py
32 lines
| 693 B
| text/x-python
|
PythonLexer
/ mercurial / pycompat.py
timeless
|
r28818 | # 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: | ||||
timeless
|
r28835 | import cStringIO as io | ||
stringio = io.StringIO | ||||
except ImportError: | ||||
import io | ||||
stringio = io.StringIO | ||||
try: | ||||
timeless
|
r28818 | import Queue as _queue | ||
timeless
|
r28833 | _queue.Queue | ||
timeless
|
r28818 | except ImportError: | ||
import queue as _queue | ||||
empty = _queue.Empty | ||||
queue = _queue.Queue | ||||
timeless
|
r28834 | |||
try: | ||||
xrange | ||||
except NameError: | ||||
import builtins | ||||
builtins.xrange = range | ||||