[PATCH 5 of 5] demandimport: reject contextlib._GeneratorContextManager on Py < 3.2

Yuya Nishihara yuya at tcha.org
Wed Sep 21 11:00:53 EDT 2016


On Wed, 21 Sep 2016 03:59:35 +0000, timeless wrote:
> # HG changeset patch
> # User timeless <timeless at mozdev.org>
> # Date 1474429683 0
> #      Wed Sep 21 03:48:03 2016 +0000
> # Node ID e07c3d398573f74a2e382deb06462bdc15ed437f
> # Parent  894cc47eb82a85d167f5717c9fe0a31392e5bb97
> # Available At https://bitbucket.org/timeless/mercurial-crew
> #              hg pull https://bitbucket.org/timeless/mercurial-crew -r e07c3d398573
> demandimport: reject contextlib._GeneratorContextManager on Py < 3.2
> 
> issue5373
> 
> diff -r 894cc47eb82a -r e07c3d398573 mercurial/demandimport.py
> --- a/mercurial/demandimport.py	Wed Sep 21 03:47:35 2016 +0000
> +++ b/mercurial/demandimport.py	Wed Sep 21 03:48:03 2016 +0000
> @@ -306,6 +306,13 @@
>      if not mod in rejects:
>          rejects[mod] = {}
>      rejects[mod][prop] = [cls, msg]
> +
> +# decorator imported by ipython from pygments does an import which isn't
> +# friendly to demandimport.
> +if sys.version_info[0] < 3 or sys.version_info[1] < 2:
> +    reject('contextlib', '_GeneratorContextManager',
> +           ImportError, 'cannot import name _GeneratorContextManager')

Can't we simply ignore 'contextlib' ?

Since contextlib is imported by demandimport.py, there's no benefit to delay
importing contextlib.


More information about the Mercurial-devel mailing list