Mercurial > hg-stable
changeset 28818:6041fb8f2da8
pycompat: add empty and queue to handle py3 divergence
While the pycompat module will actually handle divergence, please
access these properties from the util module:
util.queue = Queue.Queue / queue.Queue
util.empty = Queue.Empty / queue.Empty
author | timeless <timeless@mozdev.org> |
---|---|
date | Wed, 06 Apr 2016 20:00:49 +0000 |
parents | e1d26630443d |
children | 826d457df138 |
files | mercurial/pycompat.py mercurial/util.py |
diffstat | 2 files changed, 25 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/pycompat.py Wed Apr 06 20:00:49 2016 +0000 @@ -0,0 +1,18 @@ +# 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 Queue as _queue +except ImportError: + import queue as _queue +empty = _queue.Empty +queue = _queue.Queue
--- a/mercurial/util.py Mon Apr 04 15:39:13 2016 +0200 +++ b/mercurial/util.py Wed Apr 06 20:00:49 2016 +0000 @@ -43,8 +43,15 @@ i18n, osutil, parsers, + pycompat, ) +for attr in ( + 'empty', + 'queue', +): + globals()[attr] = getattr(pycompat, attr) + if os.name == 'nt': from . import windows as platform else: