Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 71a36f7

Browse files
committed
Issue python#24634: Importing uuid should not try to load libc on Windows
1 parent eb3c16d commit 71a36f7

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Lib/uuid.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,10 +459,14 @@ def _netbios_getnode():
459459
_uuid_generate_random = _uuid_generate_time = _UuidCreate = None
460460
try:
461461
import ctypes, ctypes.util
462+
import sys
462463

463464
# The uuid_generate_* routines are provided by libuuid on at least
464465
# Linux and FreeBSD, and provided by libc on Mac OS X.
465-
for libname in ['uuid', 'c']:
466+
_libnames = ['uuid']
467+
if not sys.platform.startswith('win'):
468+
_libnames.append('c')
469+
for libname in _libnames:
466470
try:
467471
lib = ctypes.CDLL(ctypes.util.find_library(libname))
468472
except Exception:
@@ -473,6 +477,7 @@ def _netbios_getnode():
473477
_uuid_generate_time = lib.uuid_generate_time
474478
if _uuid_generate_random is not None:
475479
break # found everything we were looking for
480+
del _libnames
476481

477482
# The uuid_generate_* functions are broken on MacOS X 10.5, as noted
478483
# in issue #8621 the function generates the same sequence of values
@@ -481,7 +486,6 @@ def _netbios_getnode():
481486
#
482487
# Assume that the uuid_generate functions are broken from 10.5 onward,
483488
# the test can be adjusted when a later version is fixed.
484-
import sys
485489
if sys.platform == 'darwin':
486490
import os
487491
if int(os.uname().release.split('.')[0]) >= 9:

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Core and Builtins
1515
Library
1616
-------
1717

18+
- Issue #24634: Importing uuid should not try to load libc on Windows
19+
1820
- Issue #24798: _msvccompiler.py doesn't properly support manifests
1921

2022
- Issue #4395: Better testing and documentation of binary operators.

0 commit comments

Comments
 (0)