diff --git a/Lib/uuid.py b/Lib/uuid.py index e21b0700757..e1b2f4b881f 100644 --- a/Lib/uuid.py +++ b/Lib/uuid.py @@ -393,7 +393,6 @@ def _netbios_getnode(): _uuid_generate_random = _uuid_generate_time = _UuidCreate = None try: import ctypes, ctypes.util - _buffer = ctypes.create_string_buffer(16) # The uuid_generate_* routines are provided by libuuid on at least # Linux and FreeBSD, and provided by libc on Mac OS X. @@ -426,11 +425,13 @@ except: def _unixdll_getnode(): """Get the hardware address on Unix using ctypes.""" + _buffer = ctypes.create_string_buffer(16) _uuid_generate_time(_buffer) return UUID(bytes=_buffer.raw).node def _windll_getnode(): """Get the hardware address on Windows using ctypes.""" + _buffer = ctypes.create_string_buffer(16) if _UuidCreate(_buffer) == 0: return UUID(bytes=_buffer.raw).node @@ -478,6 +479,7 @@ def uuid1(node=None, clock_seq=None): # When the system provides a version-1 UUID generator, use it (but don't # use UuidCreate here because its UUIDs don't conform to RFC 4122). + _buffer = ctypes.create_string_buffer(16) if _uuid_generate_time and node is clock_seq is None: _uuid_generate_time(_buffer) return UUID(bytes=_buffer.raw) @@ -514,6 +516,7 @@ def uuid4(): """Generate a random UUID.""" # When the system provides a version-4 UUID generator, use it. + _buffer = ctypes.create_string_buffer(16) if _uuid_generate_random: _uuid_generate_random(_buffer) return UUID(bytes=_buffer.raw) diff --git a/Misc/NEWS b/Misc/NEWS index 228256e915a..b92d9b09065 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -240,6 +240,8 @@ Core and builtins Library ------- +- uuid creation is now threadsafe. + - EUC-KR codec now handles the cheot-ga-keut composed make-up hangul syllables.