New submission from Steve Dower:

Lib/uuid.py includes the following code that runs on import:

    import ctypes, ctypes.util

    # 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

This code can cause issues on Windows when loading the CRT outside of an 
activation context (2.7) or in one case crashed Python 3.4 on a server 
(unfortunately I couldn't get access to the error logs - but I guessed that 
this section was responsible and turned out it was).

I propose adding a sys.platform check before running this code, to omit it on 
any platform starting with 'win' (patch to follow). I believe this should apply 
to all current versions of Python.

It is possible that someone has added their own "uuid.dll" to the DLL search 
path and is relying on that being found by uuid.py. I consider that unlikely 
and unsupported, but if people think that's a valid concern I can rework the 
patch to attempt to load uuid.dll but not the CRT on Windows.

----------
assignee: steve.dower
components: Windows
messages: 246740
nosy: paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Importing uuid should not try to load libc on Windows
type: behavior
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24634>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to