[Python-3000-checkins] r56471 - python/branches/py3k-struni/Lib/uuid.py
guido.van.rossum
python-3000-checkins at python.org
Fri Jul 20 19:45:10 CEST 2007
Author: guido.van.rossum
Date: Fri Jul 20 19:45:09 2007
New Revision: 56471
Modified:
python/branches/py3k-struni/Lib/uuid.py
Log:
Fix test_uuid.py.
Add a note that this module is thread-unsafe. :-(
Modified: python/branches/py3k-struni/Lib/uuid.py
==============================================================================
--- python/branches/py3k-struni/Lib/uuid.py (original)
+++ python/branches/py3k-struni/Lib/uuid.py Fri Jul 20 19:45:09 2007
@@ -410,6 +410,7 @@
# Thanks to Thomas Heller for ctypes and for his help with its use here.
# If ctypes is available, use it to find system routines for UUID generation.
+# XXX This makes the module non-thread-safe!
_uuid_generate_random = _uuid_generate_time = _UuidCreate = None
try:
import ctypes, ctypes.util
@@ -447,12 +448,12 @@
def _unixdll_getnode():
"""Get the hardware address on Unix using ctypes."""
_uuid_generate_time(_buffer)
- return UUID(bytes=_buffer.raw).node
+ return UUID(bytes=bytes_(_buffer.raw)).node
def _windll_getnode():
"""Get the hardware address on Windows using ctypes."""
if _UuidCreate(_buffer) == 0:
- return UUID(bytes=_buffer.raw).node
+ return UUID(bytes=bytes_(_buffer.raw)).node
def _random_getnode():
"""Get a random node ID, with eighth bit set as suggested by RFC 4122."""
@@ -500,7 +501,7 @@
# use UuidCreate here because its UUIDs don't conform to RFC 4122).
if _uuid_generate_time and node is clock_seq is None:
_uuid_generate_time(_buffer)
- return UUID(bytes=_buffer.raw)
+ return UUID(bytes=bytes_(_buffer.raw))
global _last_timestamp
import time
@@ -536,7 +537,7 @@
# When the system provides a version-4 UUID generator, use it.
if _uuid_generate_random:
_uuid_generate_random(_buffer)
- return UUID(bytes=_buffer.raw)
+ return UUID(bytes=bytes_(_buffer.raw))
# Otherwise, get randomness from urandom or the 'random' module.
try:
More information about the Python-3000-checkins
mailing list