diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2006-08-18 03:40:13 +0000 |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2006-08-18 03:40:13 +0000 |
commit | 2c3a256351488b0729437d59162e5181a3ab4dd1 (patch) | |
tree | 7e5cc003d9a4846478373a5b2abde0087b3f2fbf | |
parent | 552262409dffc06b57c64ca8bfe011b8a10b2453 (diff) | |
download | cpython-git-2c3a256351488b0729437d59162e5181a3ab4dd1.tar.gz |
Bug #1541863: uuid.uuid1 failed to generate unique identifiers
on systems with low clock resolution.
-rw-r--r-- | Lib/test/test_uuid.py | 2 | ||||
-rw-r--r-- | Lib/uuid.py | 4 | ||||
-rw-r--r-- | Misc/NEWS | 6 |
3 files changed, 9 insertions, 3 deletions
diff --git a/Lib/test/test_uuid.py b/Lib/test/test_uuid.py index 06ec51da79..90671be05d 100644 --- a/Lib/test/test_uuid.py +++ b/Lib/test/test_uuid.py @@ -429,7 +429,7 @@ class TestUUID(TestCase): # Make sure the generated UUIDs are actually unique. uuids = {} - for u in [uuid.uuid1() for i in range(1000)]: + for u in [uuid.uuid4() for i in range(1000)]: uuids[u] = 1 equal(len(uuids.keys()), 1000) diff --git a/Lib/uuid.py b/Lib/uuid.py index 684bbeb946..ae3da25ca5 100644 --- a/Lib/uuid.py +++ b/Lib/uuid.py @@ -488,8 +488,8 @@ def uuid1(node=None, clock_seq=None): # 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. timestamp = int(nanoseconds/100) + 0x01b21dd213814000L - if timestamp == _last_timestamp: - timestamp += 1 + if timestamp <= _last_timestamp: + timestamp = _last_timestamp + 1 _last_timestamp = timestamp if clock_seq is None: import random @@ -9,6 +9,12 @@ What's New in Python 2.5 ? *Release date: XX-SEP-2006* +Library +------- + +- Bug #1541863: uuid.uuid1 failed to generate unique identifiers + on systems with low clock resolution. + Build ----- |