[Python-ideas] Making it easy to prepare for PEP479

Chris Angelico rosuav at gmail.com
Mon May 18 14:51:02 CEST 2015


On Mon, May 18, 2015 at 10:07 PM, Greg Ewing
<greg.ewing at canterbury.ac.nz> wrote:
> Chris Angelico wrote:
>>
>> However, it ought to be possible to simply run your tests with
>> generator_stop active, even if that means using exec instead of
>> regular imports.
>
>
> Would it be possible for site.py to monkey-patch
> something into the __future__ module, to make
> importing it a no-op?

I doubt it; __future__ imports are special compiler magic.

>>> import __future__
>>> __future__.all_feature_names.append("asdf")
>>> __future__.asdf = __future__.with_statement
>>> from __future__ import asdf
  File "<stdin>", line 1
SyntaxError: future feature asdf is not defined

ChrisA


More information about the Python-ideas mailing list