# HG changeset patch # User Steve Dower # Date 1436905503 25200 # Tue Jul 14 13:25:03 2015 -0700 # Branch 3.5 # Node ID f94f04dc475f34184707d0f3e5a7560f8c670aab # Parent 7021d46c490e8d9d3422737c69980dc1602f90db Issue #24634: Importing uuid should not try to load libc on Windows diff --git a/Lib/uuid.py b/Lib/uuid.py --- a/Lib/uuid.py +++ b/Lib/uuid.py @@ -459,20 +459,22 @@ _uuid_generate_random = _uuid_generate_time = _UuidCreate = None try: import ctypes, ctypes.util + import sys # The uuid_generate_* routines are provided by libuuid on at least # Linux and FreeBSD, and provided by libc on Mac OS X. - for libname in ['uuid', 'c']: - try: - lib = ctypes.CDLL(ctypes.util.find_library(libname)) - except Exception: - continue - if hasattr(lib, 'uuid_generate_random'): - _uuid_generate_random = lib.uuid_generate_random - if hasattr(lib, 'uuid_generate_time'): - _uuid_generate_time = lib.uuid_generate_time - if _uuid_generate_random is not None: - break # found everything we were looking for + if not sys.platform.startswith('win'): + for libname in ['uuid', 'c']: + try: + lib = ctypes.CDLL(ctypes.util.find_library(libname)) + except Exception: + continue + if hasattr(lib, 'uuid_generate_random'): + _uuid_generate_random = lib.uuid_generate_random + if hasattr(lib, 'uuid_generate_time'): + _uuid_generate_time = lib.uuid_generate_time + if _uuid_generate_random is not None: + break # found everything we were looking for # The uuid_generate_* functions are broken on MacOS X 10.5, as noted # in issue #8621 the function generates the same sequence of values @@ -481,7 +483,6 @@ # # Assume that the uuid_generate functions are broken from 10.5 onward, # the test can be adjusted when a later version is fixed. - import sys if sys.platform == 'darwin': import os if int(os.uname().release.split('.')[0]) >= 9: