Python 3 support

Bug #665913 reported by Felix Schwarz on 2010-10-24
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pytz
Medium
Unassigned

Bug Description

pytz does not support Python 3 - however it should :-)

I was looking into Python 3 support for pytz as it is a dependency for a library of mine that I want to port to Python 3. Actually 2to3 was able to fix most issues though some manual fixes were needed afterwards. So I have a couple of rough patches and my question is if you thought about a Python 3 support strategy:

1. Single Source or separate source trees?
2. What about doctests that require a different syntax on Python3? These won't be fixed automatically. Should we skip doctests on Python 3?
3. Where things can't be fixed automatically, do you prefer explicit version testing or implicit code (with comment)?
e.g.
if sys.version_info[0] >= 3:
   …
vs.
   # in Python 3 zone is initially 'bytes', however we need 'str' (not 'unicode') for Python 2.
   zone = str(zone.decode())

Related branches

Felix Schwarz (felix-schwarz) wrote :

Forgot to mention: I have patches on my hard drive but I'd like to make sure they work in the way you like before attaching them…

Stuart Bishop (stub) wrote :

I suspect for Python 3.x support we are going to have to drop Python 2.3 support (and maybe 2.4).

lp:~stub/pytz/python3x is my stalled branch.

Changed in pytz:
status: New → Triaged
importance: Undecided → Medium
Felix Schwarz (felix-schwarz) wrote :

I have a Python 3 port of pytz on my hard disk. Currently this is a 'separate branch'-style port which means that there are manual modifications after a 2to3 run. My preferred way of porting to Python 3 is a single-source approach which would require some custom (doctest) fixers, some small changes to support Python 2&3 and possibly the use of SQLAlchemy's Preprocessor.

However as all tests pass with my modifications and I don't have enough time to finish the whole port, I add my current patch set (hg patch queue) here. There is still some stuff to clean up but at least people should be able to use pytz with Python 3 if they don't care about maintainability.

Stuart Bishop (stub) wrote :

Those patches where a big help. Thanks!

Stuart Bishop (stub) on 2011-02-08
Changed in pytz:
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers