Submitter | timeless@mozdev.org |
---|---|
Date | April 6, 2016, 9:57 p.m. |
Message ID | <10f4f7b32691075ed2f3.1459979858@waste.org> |
Download | mbox | patch |
Permalink | /patch/14401/ |
State | Accepted |
Headers | show |
Comments
On Wed, Apr 06, 2016 at 04:57:38PM -0500, timeless wrote: > # HG changeset patch > # User timeless <timeless@mozdev.org> > # Date 1459972849 0 > # Wed Apr 06 20:00:49 2016 +0000 > # Node ID 10f4f7b32691075ed2f3d9aa9301d4e54006ac55 > # Parent ea86cdcd9b50bf38c6b9dd7bbaa04b9c8cc0aefb > 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 > > diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py > new file mode 100644 > --- /dev/null > +++ b/mercurial/pycompat.py > @@ -0,0 +1,18 @@ > +# util.py - Mercurial utility functions and platform specific implementations queued with this comment fixed up > +# > +# 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 > diff --git a/mercurial/util.py b/mercurial/util.py > --- a/mercurial/util.py > +++ b/mercurial/util.py > @@ -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: > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
On Wed, 06 Apr 2016 16:57:38 -0500, timeless wrote: > # HG changeset patch > # User timeless <timeless@mozdev.org> > # Date 1459972849 0 > # Wed Apr 06 20:00:49 2016 +0000 > # Node ID 10f4f7b32691075ed2f3d9aa9301d4e54006ac55 > # Parent ea86cdcd9b50bf38c6b9dd7bbaa04b9c8cc0aefb > 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 > > diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py > new file mode 100644 > --- /dev/null > +++ b/mercurial/pycompat.py > @@ -0,0 +1,18 @@ > +# util.py - Mercurial utility functions and platform specific implementations > +# > +# 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 Again, it doesn't work with demandimport. It should be: try: import Queue queue = Queue.Queue except ImportError: ... StringIO has the same error.
Patch
diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py new file mode 100644 --- /dev/null +++ b/mercurial/pycompat.py @@ -0,0 +1,18 @@ +# util.py - Mercurial utility functions and platform specific implementations +# +# 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 diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -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: