[Python-ideas] Making it easy to prepare for PEP479
Terry Reedy
tjreedy at udel.edu
Mon May 18 16:17:06 CEST 2015
On 5/18/2015 4:14 AM, Ram Rachum wrote:
> I just heard about PEP479, and I want to prepare my open-source projects
> for it.
>
> I have no problem changing the code so it won't depend on StopIteration
> to stop generators, but I'd also like to test it in my test suite. In
> Python 3.5 I could use `from __future__ import generator_stop` so the
> test would be real (i.e. would fail wherever I rely on StopIteration to
> stop a generator). But I can't really put this snippet in my code
> because then it would fail on all Python versions below 3.5.
The purpose of future imports is to allow one to use a future feature,
at the cost of either not supporting older Python versions, or of
branching your code and making separate releases.
This future is an anomaly in that it import a future disablement of a
current feature. So you just want to make sure your one, no-branch code
base is ready for that feature removal by not using it now. You do not
want to have a separate branch and release for 3.5 with the future imports.
Try the following: add the future statement to the top of modules with
generators, compile with 3.5, and when successful, comment-out the
statement. For continued testing, especially with multiple authors,
write functions to un-comment and re-comment a file. In the test file:
if <3.5>: uncomment('xyz') # triggers re-compile on import
import xyz
if <3.5>: recomment('xyz') # ditto,
If this works, put pep479_helper on pypi.
--
Terry Jan Reedy
More information about the Python-ideas
mailing list