Skip to content

pytz for Python 3. And 2.6!

March 17, 2009

I ported pytz to Python 3, as I needed time zones, and dateutil broke 2to3, and I didn’t feel like debugging that issue. Porting pytz was quite quick, took only a couple of hours to sort out the problems, and as a bonus I was able to make it run under both 2.6 and 3.0 unmodified with very little effort. (It’s still recommended to use the normal version for Python 2.6, though).

Can be downloaded from the python-incompatibility download page.

  1. philikon permalink

    Great effort, Lennart! I just wonder why you didn’t use Bazaar to create your “fork”? After all that’s what DVCS are really good at. And with the code being hosted on Launchpad, it’s very easy:

    bzr branch lp:pytz

    You can then make your modifications in your local branch and push it back to your private area on Launchpad (see If the original authors of pytz find your patches to be of value, they can merge your branch and all your commits will be integrated into the mainline, which is undoubtedly much better than dumping a big patch at them :).

  2. I didn’t fork it, I just ran 2to3 on it, and fixed the bugs. 🙂

    The original author of pytz (Stuart Bishop) general does not answer my emails. This together with dateutil’s better support for local timezones (especially under Windows) means that pytz in my case is a stop-gap issue, because dateutil was not so quick to port. I have offered to make a proper port of pytz, i.e. change the pytz source code so that 2to3 generates correct Python 3 code, but have recieved no answer yet.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: