[Patches] [ python-Patches-1541863 ] work around clocks with low resolution (uuid.py)

SourceForge.net noreply at sourceforge.net
Fri Aug 18 05:48:22 CEST 2006


Patches item #1541863, was opened at 2006-08-17 12:44
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1541863&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: Python 2.5
>Status: Closed
Resolution: Accepted
>Priority: 8
Submitted By: Hirokazu Yamamoto (ocean-city)
Assigned to: Martin v. Löwis (loewis)
Summary: work around clocks with low resolution (uuid.py)

Initial Comment:
This patch improves workaround clocks with low
resolution yielding duplicate UUIDs. (rev51307)

Currently, windows buildbot is failing due to this bug.
http://www.python.org/dev/buildbot/trunk/x86%20XP%20trunk/builds/1390/step-test/0

Traceback (most recent call last):
  File
"C:\buildbot_py25\trunk.mcintyre-windows\build\lib\test\test_uuid.py",
line 381, in test_uuid1
    equal(len(uuids.keys()), 1000)
AssertionError: 998 != 1000

This happens because on this code (Lib/uuid.py),

   if timestamp == _last_timestamp:
       timestamp += 1
   _last_timestamp = timestamp

if timestamp is same value more than 3 times....

   timestamp == X and _last_timestamp != X:
       timestamp <- X + 1 and _last_timestamp <- X + 1

   timestamp == X: (again)
       timestamp != _last_timestamp, so timestamp is
       still X

   timestamp == X: (again)
       timestamp != _last_timestamp, so timestamp is
       still X (duplicated timestamp!)
       
I fixed this bug with attached patch.

# also fixed probably typo in test_uuid.py


----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2006-08-18 05:48

Message:
Logged In: YES 
user_id=21627

Thanks for the patch. Committed as r51353 and r51354.

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2006-08-18 05:36

Message:
Logged In: YES 
user_id=33168

Thanks for the patch!

Assuming this fixes the problem on Windows, someone please
test this and check it in.  Don't forget, head and 2.5
branch.  Needs updates to Misc/{NEWS,ACKS}

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2006-08-17 22:05

Message:
Logged In: YES 
user_id=21627

>From inspection, the patch looks right to me (although i
haven't tested it). I think it should go into 2.5.

----------------------------------------------------------------------

Comment By: Hirokazu Yamamoto (ocean-city)
Date: 2006-08-17 21:00

Message:
Logged In: YES 
user_id=1200846

Sorry, my explanation was wrong.

timestamp == X and _last_timestamp != X:
timestamp remains X, and _last_timestamp becomes X

timestamp == X: (again)
timestamp == _last_timestamp, so timestamp and
_last_timestamp becomes X + 1.

timestamp == X: (again)
timestamp != _last_timestamp, so timestamp remains X
(duplicated timestamp!)


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1541863&group_id=5470


More information about the Patches mailing list