[openstack-dev] [swift] Plan to port Swift to Python 3

Victor Stinner vstinner at redhat.com
Thu Oct 8 14:58:15 UTC 2015


Hi,

Good news, we made good progress last weeks on porting Swift to Python 
3, a few changes were merged and all dependencies now work on Python 3. 
We only need two more simple changes to have a working pyhon34 check job:

* "py3: Update pbr and dnspython requirements"
   https://review.openstack.org/#/c/217423/
* "py3: Add py34 test environment to tox"
   https://review.openstack.org/#/c/199034/

With these changes, it will be possible to make the python34 check job 
voting to avoid Python 3 regressions. It's very important to avoid 
regressions, so we cannot go backward again in Python 3 support.

On IRC, it was said that it's better to merge Python 3 changes at the 
beginning of the Mitaka cycle, because Python 3 requires a lot of small 
changes which can likely introduce (subtle) bugs, and it's better to 
catch them early during the development cycle.

John Dickinson prefers incremental and small changes, whereas clayg 
looks to like giant patches to fix all Python 3 issues at once to avoid 
conflicts in other (non-Python3) changes. (Sorry, if I didn't summarized 
correctly the discussion we had yesterday.)

The problem is that it's hard to fix "all" Python 3 issues in a single 
patch, the patch would be super giant and just impossible to review. 
It's also annoying to have to write dozens of small patches: we loose 
time on merge conflicts, rebasing, random gate failures, etc.

I proposed a first patch serie of 6 changes to fix a lot of simple 
Python 3 issues "at once":

* "py3: Replace unicode with six.text_type"
   https://review.openstack.org/#/c/232476/

* "py3: Replace urllib imports with six.moves.urllib"
   https://review.openstack.org/#/c/232536/

* "py3: Use six.reraise() to reraise an exception"
   https://review.openstack.org/#/c/232537/

* "py3: Replace gen.next() with next(gen)"
   https://review.openstack.org/#/c/232538/

* "Replace itertools.ifilter with six.moves.filter"
   https://review.openstack.org/#/c/232539/

* "py3: Replace basestring with six.string_types"
   https://review.openstack.org/#/c/232540/

The overall diff is impressive: "61 files changed, 233 insertions(+), 
189 deletions(-)" ... but each change is quite simple. It's only one 
pattern replaced with a different pattern. For example, replace 
"unicode" with "six.text_type" (and add "import six" if needed). So 
these changes should be easy to review.

With a working (and voting?) python34 check job and these 6 changes, it 
will be (much) easier to work on porting Swift to Python 3. Following 
patches will be validated by the python34 check job, shorter and 
restricted to a few files.

Victor



More information about the OpenStack-dev mailing list