[pycrypto] Once again: Python3 with PyCrypto
Thorsten Behrens
sbehrens at gmx.li
Sun Dec 26 14:24:40 CST 2010
Quick update on where this stands right now.
As predicted, the module handling changes with Python 3.x were a pain. I
think I have them under control now. At least "python setup.py test" no
longer crashes immediately. It now gets far enough to complain about
bytes/unicode errors.
I haven't attempted _fastmath.c on Python 3.x yet. I'll do that last,
when everything else works.
C modules will give link-time errors, like so: "_counter.obj : warning
LNK4197: export 'init_counter' specified multiple times; using first
specification". This is an issue in distutils. See python issue 9709.
There's nothing we can do until Python fixes distutils - of course any
pre-compiled binaries can be built with the distutils fix in, and the
README can warn people of this.
The code still works with Python27, but I broke Python21. Specifically,
I am having a hard time with string literals. The main work remaining
now is to flush out string to bytes/unicode changes between 2.x and 3.x,
and adapt the code. I thought I had this licked, but I clearly don't.
I am currently not handling literals well. This is what I tried:
if sys.version_info[0] is 2:
seed = "".join(seed)
else:
seed = b"".join(seed)
And that gives a "SyntaxError: invalid syntax" at run time. Of course it
does.
django has been moved to be 2.x/3.x compatible. I'll see what they did
and try to replicate it. I'm hoping it'll take care of these type of issues.
Assignment to True and False in pycrypto_compat.py is an issue. Right
now, I just don't import pycrypto_compat.py when Python 3.x is detected.
That still gives install-time errors on Python 3.x. The only option I
can think of right now is to exclude the offending file from install in
setup.py if Python 3.x is detected.
Thorsten
More information about the pycrypto
mailing list