Maintaining a backported module

Steven D'Aprano steve at pearwood.info
Thu Oct 24 05:38:35 EDT 2013


On Thu, 24 Oct 2013 17:59:59 +1100, 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>.

I too have written code that supports 2.4 - 3.3 (although only relatively 
small modules). That's not the problem here. My problem is that I have 
two chunks of code:

1) statistics.py in the standard library, which is written for 
   Python 3.3/3.4 only, and should be as clean as possible;

2) a backport of it, on PyPI, which will support older Pythons, and
   may be slower/uglier if need be.

My problem is not supporting 2.7 and 3.4 in the one code base. My problem 
is, how do I prevent #1 and #2 from gradually diverging?

The easy answer is "unit tests", but the unit tests for 1) are in the std 
lib and target 3.4, while the unit tests for 2) will be on PyPI and 
won't. So how do I keep the unit tests from diverging?



-- 
Steven



More information about the Python-list mailing list