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
39aef891
Commit
39aef891
authored
Aug 24, 2007
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
uuid creation is now threadsafe, backport from py3k rev. 57375.
parent
5f59b776
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
1 deletion
+6
-1
Lib/uuid.py
Lib/uuid.py
+4
-1
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/uuid.py
View file @
39aef891
...
...
@@ -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
)
...
...
Misc/NEWS
View file @
39aef891
...
...
@@ -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.
...
...
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