summaryrefslogtreecommitdiff
path: root/Lib/test/test_uuid.py
diff options
context:
space:
mode:
authorRonald Oussoren <ronaldoussoren@mac.com>2010-05-05 14:48:37 +0000
committerRonald Oussoren <ronaldoussoren@mac.com>2010-05-05 14:48:37 +0000
commit332069637162c46dbad433ef1b620742a56af430 (patch)
tree7d0719262769f8f4272d3b9f9a815a6e1dce6f60 /Lib/test/test_uuid.py
parent9b90f7af492e0e4b5b3011c9b5e6207d4cdf0f8c (diff)
downloadcpython-git-332069637162c46dbad433ef1b620742a56af430.tar.gz
The C function used by uuid.uuid4 is broken on
OSX 10.6 in that after os.fork() the parent and child generate the same sequence of UUIDs. This patch falls back to the the Python implementation on OSX 10.6 or later. Fixes issue #8621.
Diffstat (limited to 'Lib/test/test_uuid.py')
-rw-r--r--Lib/test/test_uuid.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/Lib/test/test_uuid.py b/Lib/test/test_uuid.py
index cc21baef5d..d10195651c 100644
--- a/Lib/test/test_uuid.py
+++ b/Lib/test/test_uuid.py
@@ -446,6 +446,34 @@ class TestUUID(TestCase):
equal(u, uuid.UUID(v))
equal(str(u), v)
+ def testIssue8621(self):
+ import os
+ import sys
+ if os.name != 'posix':
+ return
+
+ # On at least some versions of OSX uuid.uuid4 generates
+ # the same sequence of UUIDs in the parent and any
+ # children started using fork.
+ fds = os.pipe()
+ pid = os.fork()
+ if pid == 0:
+ os.close(fds[0])
+ value = uuid.uuid4()
+ os.write(fds[1], value.hex)
+ sys.exit(0)
+
+ else:
+ os.close(fds[1])
+ parent_value = uuid.uuid4().hex
+ os.waitpid(pid, 0)
+ child_value = os.read(fds[0], 100)
+
+ self.assertNotEqual(parent_value, child_value)
+
+
+
+
def test_main():
test_support.run_unittest(TestUUID)