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

timeless timeless at gmail.com
Wed Sep 21 14:47:34 EDT 2016


Yuya Nishihara wrote:
> Can't we simply ignore 'contextlib' ?

I had a patch that did that. It felt gross (it clearly wasn't very elegant)

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

So, demandimport could just return a given module if it's already
loaded w/o wrapping things,
but it's possible for a module to be loaded w/o its submodules being loaded.

We don't want to automatically load all submodules (that would more or
less bypass demandimport, and thus defeat its purpose).

I think that other modules have similarly unfriendly code, and that it
thus makes sense to offer this feature.

After looking through our list of ignores, I think that it should be
possible to make distutils.msvc9compiler work with my general approach
(although the specific implementation I have in v1 and v2 doesn't
work, so I'll need a v3).


More information about the Mercurial-devel mailing list