summaryrefslogtreecommitdiff
path: root/Lib/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/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/uuid.py')
-rw-r--r--Lib/uuid.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/uuid.py b/Lib/uuid.py
index 6aaa2b4751..d915fb2640 100644
--- a/Lib/uuid.py
+++ b/Lib/uuid.py
@@ -406,6 +406,19 @@ try:
if hasattr(lib, 'uuid_generate_time'):
_uuid_generate_time = lib.uuid_generate_time
+ # The uuid_generate_* functions are broken on MacOS X 10.6, as noted
+ # in issue #8621 the function generates the same sequence of values
+ # in the parent process and all children created using fork (unless
+ # those children use exec as well).
+ #
+ # Assume that the uuid_generate functions are broken from 10.6 onward,
+ # the test can be adjusted when a later version is fixed.
+ import sys
+ if sys.platform == 'darwin':
+ import os
+ if int(os.uname()[2].split('.')[0]) >= 10:
+ _uuid_generate_random = _uuid_generate_time = None
+
# On Windows prior to 2000, UuidCreate gives a UUID containing the
# hardware address. On Windows 2000 and later, UuidCreate makes a
# random UUID and UuidCreateSequential gives a UUID containing the