[pycrypto] Once again: Python3 with PyCrypto

Thorsten Behrens sbehrens at gmx.li
Thu Dec 23 19:20:28 CST 2010


Dwayne,

I've looked into this some more. There are two basic approaches:

a) Create .py code that will work in Python 2.x and 3.x. Code will 
become uglier; for example try except blocks have to be used for 
imports. One can catch a glimpse here: 
http://pydev.blogspot.com/2008/11/making-code-work-in-python-2-and-3.html

b) Leave .py code to be written for Python 2.x, with some cleanup 
applied to redo constructs that cannot be converted by 2to3. When ready 
to release, run 2to3 on the source tree, and release two versions: One 
for Python 2.x, one for Python 3.x.

b) is how the authors of Python intend things to be, and is likely the 
cleanest way of operation. I don't relish the idea of following a) and 
butchering the 2.x code so it will run in both 2.x and 3.x without change.

The C code will require some #defines and some #ifdefs in places, to 
deal with int/long, the fact that bytes are a type now and shouldn't be 
strings (can be done with defines), and the module initialization code.

Are you comfortable with b)? Objections? Reservations?

If you are good to give it a go, I'd need to know from you how you like 
to handle branches in git. I'd assume that this work should be carried 
out in a separate branch, not the trunk. This is going to touch a lot of 
files.

Yours
Thorsten



More information about the pycrypto mailing list