[Python-Dev] test_uuid.py on HP NonStop Python-2.7.5 fails (test case: testIssue8621)

V S, Nagendra (Nonstop Filesystems Team) nagendra.vs at hp.com
Thu Nov 28 07:14:22 CET 2013


Hi,
We are porting python to HP NonStop & to a large extent we have been successful. While running the unit tests we happen to hit upon the problem reported in issue8621(http://bugs.python.org/issue8621), i.e uuid4 sequences on both parent & child were same . On NonStop we lack support for both hardware randomness & uuid_generate family of calls, so on NonStop "uuid.py" falls throw to  random.range() call to generate the random number which in turn is used by the UUID class. Below the code snip that can used to repo the problem...

#!/usr/bin/python
import os
import sys
import uuid
import random

#Code taken from Lib/uuid.py

def myuuid():
    bytes = [chr(random.randrange(256)) for i in range(16)]
    val = uuid.UUID(bytes=bytes, version=4)
    return val

# Code taken from Lib/test/test_uuid.py
#
# On at least some versions of OSX myuuid generates
# the same sequence of UUIDs in the parent and any
# children started using fork.
for i in range(10):
    fds = os.pipe()
    pid = os.fork()
    if pid == 0:
        os.close(fds[0])
        value = myuuid()
        os.write(fds[1], value.hex)
        os._exit(0)
    else:
        os.close(fds[1])
        parent_value = myuuid().hex
        os.waitpid(pid, 0)
        child_value = os.read(fds[0], 100)
        os.close(fds[0])
        print parent_value, child_value, (parent_value == child_value)

We also ran the above test on Linux & were seeing the same results as on NonStop, i.e uuid4 sequences on both parent & child were same. 
Output snippet.....

[vsnag@<hostname>  Python-2.7.5]$ uname -a
Linux <hostname> 2.6.32-71.el6.x86_64 #1 SMP Wed Sep 1 01:33:01 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
[vsnag@<hostname>  Python-2.7.5]$ ./python test.py
2b512ef47c9f471a829148ca4e779dff 2b512ef47c9f471a829148ca4e779dff True
e39b605476e04ca2b992b5d055278c3b e39b605476e04ca2b992b5d055278c3b True
8249fb9f6a2045c084da549c9e393a51 8249fb9f6a2045c084da549c9e393a51 True
e1d9e84b7f134930abf5fb2760f07585 e1d9e84b7f134930abf5fb2760f07585 True
068f9612f0744eeb92dbca8950028a3c 068f9612f0744eeb92dbca8950028a3c True
e85df457614f47d5b6300186bdd1c798 e85df457614f47d5b6300186bdd1c798 True
a8628a0817b843778e9565b835b8cfac a8628a0817b843778e9565b835b8cfac True
478d8e9e5090498e9fad5356c5ae9568 478d8e9e5090498e9fad5356c5ae9568 True
151d7f1c8f8b42099a89a0f442e98dc7 151d7f1c8f8b42099a89a0f442e98dc7 True
838571b03a5b46f8a06398e020647d89 838571b03a5b46f8a06398e020647d89 True
[vsnag@<hostname>  Python-2.7.5]$

 Any thoughts what could be going wrong....?

Thanks & Regards
Nagendra.V.S


More information about the Python-Dev mailing list