Maintaining a backported module
Ned Batchelder
ned at nedbatchelder.com
Thu Oct 24 06:36:04 EDT 2013
On 10/24/13 2:59 AM, Ben Finney wrote:
> Steven D'Aprano <steve at pearwood.info> writes:
>
>> I'm now at the point where I wish to backport this module to support
>> versions of Python back to 3.1 at least and possibly 2.7, and put it
>> up on PyPI.
> Ned Batchelder has managed something at least as ambitious (supporting
> Python versions 2.4 through 3.3), which should be helpful in your case
> <URL:http://nedbatchelder.com/blog/200910/running_the_same_code_on_python_2x_and_3x.html>.
FWIW, coverage.py currently runs on 2.3 through 3.4. It mostly comes
down to:
1. avoiding newer features (decorators! generator expressions! rpartition!),
2. using a compatibility layer like "six" (though I started my own
called backward.py before six existed),
3. using some awkward syntax workarounds (sys.exc_info()[1] to get the
current exception),
4. somehow finding a way to test on all those versions (pythonz helps,
and you have to limit your dependencies).
Also, I've just started the coverage.py 4.x branch, which will run on
>=2.6 and >=3.2, and it's very nice to get rid of some of that
compatibility stuff.
--Ned.
> Eli Bendersky also has an article with specific advice
> <URL:http://eli.thegreenplace.net/2010/05/19/making-code-compatible-with-python-2-and-3/>.
>
More information about the Python-list
mailing list