summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_uuid.py
diff options
context:
space:
mode:
authorRonald Oussoren <ronaldoussoren@mac.com>2010-05-05 15:33:55 (GMT)
committerRonald Oussoren <ronaldoussoren@mac.com>2010-05-05 15:33:55 (GMT)
commitc51527dca4cdf47163f5b3a0bc929548a7703a6c (patch)
treea034ef0d4eb8a1204a041c3e3ac606cf4c6d3f84 /Lib/test/test_uuid.py
parentde4bcd92f9eeea07e9157033c785c776384f8a72 (diff)
downloadcpython-c51527dca4cdf47163f5b3a0bc929548a7703a6c.zip
cpython-c51527dca4cdf47163f5b3a0bc929548a7703a6c.tar.gz
cpython-c51527dca4cdf47163f5b3a0bc929548a7703a6c.tar.bz2
Merged revisions 80786 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r80786 | ronald.oussoren | 2010-05-05 17:32:33 +0200 (Wed, 05 May 2010) | 16 lines Merged revisions 80784 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r80784 | ronald.oussoren | 2010-05-05 16:48:37 +0200 (Wed, 05 May 2010) | 9 lines 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 696ffb1..a1663c5 100644
--- a/Lib/test/test_uuid.py
+++ b/Lib/test/test_uuid.py
@@ -451,6 +451,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.encode('latin1'))
+ os._exit(0)
+
+ else:
+ os.close(fds[1])
+ parent_value = uuid.uuid4().hex
+ os.waitpid(pid, 0)
+ child_value = os.read(fds[0], 100).decode('latin1')
+
+ self.assertNotEqual(parent_value, child_value)
+
+
+
+
def test_main():
support.run_unittest(TestUUID)