[PATCH 3 of 3 v3] demandimport: reject contextlib._GeneratorContextManager on Py < 3.2
Yuya Nishihara
yuya at tcha.org
Mon Sep 26 10:09:02 EDT 2016
On Wed, 21 Sep 2016 19:09:34 +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 0070696439eab002f6dd32bcb40eb671daff800a
> # Parent adb54fd7d90f0ca607432ed7ae884da55ec427de
> # Available At https://bitbucket.org/timeless/mercurial-crew
> # hg pull https://bitbucket.org/timeless/mercurial-crew -r 0070696439ea
> demandimport: reject contextlib._GeneratorContextManager on Py < 3.2
>
> decorator expects:
> from contextlib import _GeneratorContextManager
> to throw an exception on python < 3.2 (issue5373).
>
> We tell demandimport to throw it.
>
> diff -r adb54fd7d90f -r 0070696439ea mercurial/demandimport.py
> --- a/mercurial/demandimport.py Wed Sep 21 18:58:54 2016 +0000
> +++ b/mercurial/demandimport.py Wed Sep 21 03:48:03 2016 +0000
> @@ -313,6 +313,12 @@
> if os.name != 'nt':
> reject('distutils', 'msvc9compiler', ImportError, 'No module named _winreg')
>
> +# 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')
I'm not a fan of duplicating knowledge about module internals unless there's
a measurable win. We could break the current "ignore" list down to fine-tuned
"rejects" rules, but that would end with bloated set of rules we wouldn't
want to maintain.
More information about the Mercurial-devel
mailing list