]> granicus.if.org Git - python/commitdiff
Avoid using the obsolete rand module; and improve the randomness
authorGuido van Rossum <guido@python.org>
Sat, 11 Apr 1998 03:06:02 +0000 (03:06 +0000)
committerGuido van Rossum <guido@python.org>
Sat, 11 Apr 1998 03:06:02 +0000 (03:06 +0000)
of the boundary chosen by choose_boudary() by using milliseconds
of the timestamp.

Lib/mimetools.py

index 5489aa090c4c6c77ca10e438bd236a1a63a3deab..eed24ca0af1710a719cb915e325d8fdd6d8c3f8d 100644 (file)
@@ -109,7 +109,7 @@ _prefix = None
 def choose_boundary():
        global _prefix
        import time
-       import rand
+       import whrandom
        if _prefix == None:
                import socket
                import os
@@ -122,10 +122,9 @@ def choose_boundary():
                    pid = `os.getpid()`
                except:
                    pid = '1'
-               seed = `rand.rand()`
                _prefix = hostid + '.' + uid + '.' + pid
-       timestamp = `int(time.time())`
-       seed = `rand.rand()`
+       timestamp = '%.3f' % time.time()
+       seed = `whrandom.randint(0, 32767)`
        return _prefix + '.' + timestamp + '.' + seed