Skip to content

WIP: Python 3 compatibility

Alex Pearce requested to merge apearce/Gaudi:apearce-python3 into master

This MR tries to make Gaudi a Python-3-first project, supporting Python 3 primarily, and adding Python 2.6+ compatibility where needed. This is mostly done with 'pure' Python, e.g. try/except when importing a module that's changed between the two versions, but I've also used the six module occassionally, when it's cleaner.

As one might expect, there are quite a few changes. I've tried my best to separate each 'class' of change into individual commits, so although there are a lot of commits, each one is pretty small and should be reasonably self-contained.

So far, on my development machine, Gaudi successfully builds against LCG_91python3, and a majority of the test cases pass. There are a couple of common features amongst the failing tests:

  1. The behaviour of the pprint module is different in Python 3, as it now tries to wrap strings as well as other objects;
  2. The behaviour of print is different with respect to flushing.

This causes the test out not to match the references. Number 2 we can fix with some liberal applications of print(..., flush=True), but number 1 is more annoying.

Otherwise, there are several corner-cases that need individual attention. Good test coverage is cruicial in a smooth 2-to-3 transition, and it's easy to miss things (e.g. the change in behaviour of integer division).

I'll keep working on this MR to reduce the number of failing tests. For now, I intend to regularly rebase this MR, so that when I find something that's in a similar class to a commit I've already made, I can just update that commit, rather than create a new one.

Merge request reports