<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#330033" bgcolor="#ffffff">
On 12/27/2010 9:16 PM, Thorsten Behrens wrote:<br>
<blockquote cite="mid:4D1972A2.4080305@gmx.li" type="cite">
<pre wrap="">If you can think of a reasonably clean way of handling the "/" vs. "//"
issue - or if anyone else can - please share.
Barring that, I think my message is: If Python 3.x is to be supported
without code duplication, Python 2.1 support may have to go.
Yours
Thorsten
# if e is given make sure that e and X-1 are coprime
# this is not necessarily a strong prime criterion but useful when
# creating them for RSA where the p-1 and q-1 should be coprime to
# the public exponent e
if e and is_possible_prime:
if e & 1:
if GCD (e, X-1) != 1:
is_possible_prime = 0
else:
# Python 2.1 does not understand //, and 3.x returns a
float on /
# Infinite loop, wheee!!!
if GCD (e, (X-1)//2) != 1:
is_possible_prime = 0
</pre>
</blockquote>
<br>
Ugly hack, not sure if it is worthwhile.<br>
<br>
utils.py:<br>
def slashslash( a, b ):<br>
return a / b<br>
<br>
utilsnew.py:<br>
def slashslash( a, b ):<br>
return a // b<br>
<br>
in numbers.py:<br>
<br>
if sys.version_info[ 0 ] <= 2 and sys.version_info[ 1 ] <= 1:<br>
import utils<br>
else:<br>
import utilsnew as utils<br>
...<br>
if GCD ( e,
utils.slashslash(X-1,2) != 1:<br>
<br>
# Not sure if 2.1 will ignore "as" if not executed? If not, then
you play the setup.py with a tiny file.<br>
</body>
</html>