[Python-Dev] random.py still broken wrt. urandom

"Martin v. Löwis" martin at v.loewis.de
Sat Sep 4 15:12:10 CEST 2004


I consider the random module still broken in its current form (1.66).
It tries to invoke random.urandom(1) in order to find out whether
urandom works. Instead, it should defer that determination until
urandom is actually used; i.e. instead of

             if _urandom is None:
                 import time
                 a = long(time.time() * 256) # use fractional seconds
             else:
                 a = long(_hexlify(_urandom(16)), 16)

it should read

             try:
                 a = long(_hexlify(os.urandom(16)), 16)
             except NotImplementedError:
                 import time
                 a = long(time.time() * 256) # use fractional seconds

IMO the patch to random.py should not have been applied without a
review.

Regards,
Martin


More information about the Python-Dev mailing list