Michael Felt <mich...@felt.demon.nl> added the comment:

Actually, the libc/libuuid function called should be setting the 
version/variant values as well.

So, I think the AMD64 FreeBSD 10.x Shared 3.x uuid_generate() function is wrong 
(if that is what it is using - was it/can it also use the uuid_generate* 
routines?

FYI:

I notice the AIX include file does not actually define the bits for RFC_4122, 
etc.., but the include file comments does show that the implementation is 
taking them into account.

/** The strlen() of a UUID string (does not include terminating null) */
#define UUID_STRLEN 36
/**
 * Constant value indicating an as-yet undetermined UUID for a thing.  Spells \c
 * "\0\0UUID\x10_\x80UNKNOWN" in ASCII.  Zeroes at the top make it very unlikely
 * to collide with a uuid_create()d value, which puts a timestamp in that spot.
 * The \c "\x10" and \c "\x80" are reserved/version/mask bits that make this
 * conform to the format expected by the uuid.h API.
 */
#define UUID_UNKNOWN (uuid_t){0x00005555, 0x4944, 0x105F, 0x80, 0x55, {0x4E, 
0x4B, 0x4E, 0x4F, 0x57, 0x4E}}
#define UUID_UNKNOWN_STR       "00005555-4944-105f-8055-4e4b4e4f574e"

I wrote a simple program to examine uuid for myself.

Maybe - if you ran a loop (looking at uuid1().variant and uuid1().version you 
could see if there is an incorrect version showing up. Rather than python - 
that would seem to be a library function error.

My very simple program:

cat -n ../x4.py
     1  import _uuid
     2  import uuid
     3  _generate_time_safe = _uuid.generate_time_safe
     4  _has_uuid_generate_time_safe = _uuid.has_uuid_generate_time_safe
     5  uuid_time, _ = _generate_time_safe()
     6
     7  uu1a = uuid.UUID(bytes=uuid_time)
     8  uu1b = uuid.uuid1()
     9  uu4 = uuid.uuid4()
    10
    11  print("a)uuid1 = %x" % uu1a.int)
    12  print("b)uuid1 = %x" % uu1b.int)
    13  print("")
    14  print("a uuid1 = ",uu1a.fields, uu1a.version, uu1a.variant)
    15  print("b uuid1 = ",uu1b.fields, uu1b.version, uu1b.variant)
    16  uu1c = uuid.uuid1()
    17  print("c uuid1 = ",uu1c.fields, uu1c.version, uu1c.variant)
    18  print("")
    19  print("  uuid4 = %x" % uu4.int)
    20  print("  uuid4 = ",uu4.fields, uu4.version, uu4.variant)
    21  print("")
    22  uu4 = uuid.uuid4()
    23  print("  uuid4 = %x" % uu4.int)
    24  print("  uuid4 = ",uu4.fields, uu4.version, uu4.variant)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32493>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to