mirror of
https://github.com/python/cpython.git
synced 2025-08-22 01:35:16 +00:00
Bug #1541863: uuid.uuid1 failed to generate unique identifiers
on systems with low clock resolution.
This commit is contained in:
parent
552262409d
commit
2c3a256351
3 changed files with 9 additions and 3 deletions
|
@ -429,7 +429,7 @@ class TestUUID(TestCase):
|
||||||
|
|
||||||
# Make sure the generated UUIDs are actually unique.
|
# Make sure the generated UUIDs are actually unique.
|
||||||
uuids = {}
|
uuids = {}
|
||||||
for u in [uuid.uuid1() for i in range(1000)]:
|
for u in [uuid.uuid4() for i in range(1000)]:
|
||||||
uuids[u] = 1
|
uuids[u] = 1
|
||||||
equal(len(uuids.keys()), 1000)
|
equal(len(uuids.keys()), 1000)
|
||||||
|
|
||||||
|
|
|
@ -488,8 +488,8 @@ def uuid1(node=None, clock_seq=None):
|
||||||
# 0x01b21dd213814000 is the number of 100-ns intervals between the
|
# 0x01b21dd213814000 is the number of 100-ns intervals between the
|
||||||
# UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01 00:00:00.
|
# UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01 00:00:00.
|
||||||
timestamp = int(nanoseconds/100) + 0x01b21dd213814000L
|
timestamp = int(nanoseconds/100) + 0x01b21dd213814000L
|
||||||
if timestamp == _last_timestamp:
|
if timestamp <= _last_timestamp:
|
||||||
timestamp += 1
|
timestamp = _last_timestamp + 1
|
||||||
_last_timestamp = timestamp
|
_last_timestamp = timestamp
|
||||||
if clock_seq is None:
|
if clock_seq is None:
|
||||||
import random
|
import random
|
||||||
|
|
|
@ -9,6 +9,12 @@ What's New in Python 2.5 ?
|
||||||
|
|
||||||
*Release date: XX-SEP-2006*
|
*Release date: XX-SEP-2006*
|
||||||
|
|
||||||
|
Library
|
||||||
|
-------
|
||||||
|
|
||||||
|
- Bug #1541863: uuid.uuid1 failed to generate unique identifiers
|
||||||
|
on systems with low clock resolution.
|
||||||
|
|
||||||
Build
|
Build
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue