diff options
author | Guido van Rossum <guido@python.org> | 1998-04-11 03:06:02 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-04-11 03:06:02 (GMT) |
commit | 5c7e8cd26727fe9c32c286d5d051def4f0c29646 (patch) | |
tree | d74cef978f9008e3342df8f804fc95b929815c6e /Lib | |
parent | 5fb2b61c6454d24a2b69e3444321cea1f6974e1f (diff) | |
download | cpython-5c7e8cd26727fe9c32c286d5d051def4f0c29646.zip cpython-5c7e8cd26727fe9c32c286d5d051def4f0c29646.tar.gz cpython-5c7e8cd26727fe9c32c286d5d051def4f0c29646.tar.bz2 |
Avoid using the obsolete rand module; and improve the randomness
of the boundary chosen by choose_boudary() by using milliseconds
of the timestamp.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/mimetools.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/Lib/mimetools.py b/Lib/mimetools.py index 5489aa0..eed24ca 100644 --- a/Lib/mimetools.py +++ b/Lib/mimetools.py @@ -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 |