|Ned Batchelder : Blog | Code | Text | Site|
» Home : Blog : December 2012
One of my crazy decisions about coverage.py is to keep it running on Python 2.3 and up. One of the reasons this is difficult is that I've switched to using tox to test, and tox only supports >=2.5, so actually testing on 2.3 has fallen behind.
It's also really easy to forget what's not allowed in 2.3. During the bug-fixing frenzy in the latest beta, I accidentally broke 2.3 support in a few ways: combined try/except/finally, imports with parentheses, and rpartition.
For the first two, I just had to change the statements to use the old style, but I didn't want to give up rpartition, it's too useful. So I implemented it myself.
My first thought was to implement it in terms of partition, by reversing everything, using partition, then reversing everything back. It's one of the oddest-looking functions I've written:
Too bad I couldn't have gotten one more [::-1] in there to reverse the return tuple, but that would just be weird for the sake of it...
Unfortunately, after I got this working, I discovered that partition and rpartition appeared at the same time, so implementing one in terms of the other wouldn't help me with backward compatibility. So I had to use a much less interesting implementation:
Now 2.3 is back in the house. One of these days, I'll drop it, but I like the idea of being able to provide the latest coverage.py to anyone who wants it.
tagged: python» 1 reaction