diff -r fe6c7771c25c Lib/uuid.py --- a/Lib/uuid.py Wed Sep 14 14:56:32 2011 -0700 +++ b/Lib/uuid.py Thu Sep 15 12:11:37 2011 -0400 @@ -558,14 +558,9 @@ _uuid_generate_random(_buffer) return UUID(bytes=bytes_(_buffer.raw)) - # Otherwise, get randomness from urandom or the 'random' module. - try: - import os - return UUID(bytes=os.urandom(16), version=4) - except: - import random - bytes = bytes_(random.randrange(256) for i in range(16)) - return UUID(bytes=bytes, version=4) + # Otherwise, get randomness from the 'random' module. + import random + return UUID(int=random.getrandbits(128), version=4) def uuid5(namespace, name): """Generate a UUID from the SHA-1 hash of a namespace UUID and a name."""