Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
37410aa0
Commit
37410aa0
authored
Aug 24, 2007
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make uuid.py thread-safe. Fix by Yuri Ginsburg.
parent
fd53fd62
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletion
+4
-1
Lib/uuid.py
Lib/uuid.py
+4
-1
No files found.
Lib/uuid.py
View file @
37410aa0
...
@@ -414,7 +414,6 @@ def _netbios_getnode():
...
@@ -414,7 +414,6 @@ def _netbios_getnode():
_uuid_generate_random
=
_uuid_generate_time
=
_UuidCreate
=
None
_uuid_generate_random
=
_uuid_generate_time
=
_UuidCreate
=
None
try
:
try
:
import
ctypes
,
ctypes
.
util
import
ctypes
,
ctypes
.
util
_buffer
=
ctypes
.
create_string_buffer
(
16
)
# The uuid_generate_* routines are provided by libuuid on at least
# The uuid_generate_* routines are provided by libuuid on at least
# Linux and FreeBSD, and provided by libc on Mac OS X.
# Linux and FreeBSD, and provided by libc on Mac OS X.
...
@@ -447,11 +446,13 @@ except:
...
@@ -447,11 +446,13 @@ except:
def
_unixdll_getnode
():
def
_unixdll_getnode
():
"""Get the hardware address on Unix using ctypes."""
"""Get the hardware address on Unix using ctypes."""
_buffer
=
ctypes
.
create_string_buffer
(
16
)
_uuid_generate_time
(
_buffer
)
_uuid_generate_time
(
_buffer
)
return
UUID
(
bytes
=
bytes_
(
_buffer
.
raw
)).
node
return
UUID
(
bytes
=
bytes_
(
_buffer
.
raw
)).
node
def
_windll_getnode
():
def
_windll_getnode
():
"""Get the hardware address on Windows using ctypes."""
"""Get the hardware address on Windows using ctypes."""
_buffer
=
ctypes
.
create_string_buffer
(
16
)
if
_UuidCreate
(
_buffer
)
==
0
:
if
_UuidCreate
(
_buffer
)
==
0
:
return
UUID
(
bytes
=
bytes_
(
_buffer
.
raw
)).
node
return
UUID
(
bytes
=
bytes_
(
_buffer
.
raw
)).
node
...
@@ -499,6 +500,7 @@ def uuid1(node=None, clock_seq=None):
...
@@ -499,6 +500,7 @@ def uuid1(node=None, clock_seq=None):
# When the system provides a version-1 UUID generator, use it (but don't
# 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).
# 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
:
if
_uuid_generate_time
and
node
is
clock_seq
is
None
:
_uuid_generate_time
(
_buffer
)
_uuid_generate_time
(
_buffer
)
return
UUID
(
bytes
=
bytes_
(
_buffer
.
raw
))
return
UUID
(
bytes
=
bytes_
(
_buffer
.
raw
))
...
@@ -535,6 +537,7 @@ def uuid4():
...
@@ -535,6 +537,7 @@ def uuid4():
"""Generate a random UUID."""
"""Generate a random UUID."""
# When the system provides a version-4 UUID generator, use it.
# When the system provides a version-4 UUID generator, use it.
_buffer
=
ctypes
.
create_string_buffer
(
16
)
if
_uuid_generate_random
:
if
_uuid_generate_random
:
_uuid_generate_random
(
_buffer
)
_uuid_generate_random
(
_buffer
)
return
UUID
(
bytes
=
bytes_
(
_buffer
.
raw
))
return
UUID
(
bytes
=
bytes_
(
_buffer
.
raw
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment