bpo-32493: Fix uuid.uuid1() on FreeBSD. - #7099
Conversation
|
@vstinner, any opinion? |
| uint32_t status; | ||
| uuid_create(&uuid, &status); | ||
| # if defined(HAVE_UUID_ENC_BE) | ||
| unsigned char buf[sizeof(uuid)]; |
There was a problem hiding this comment.
The size should be 16 bytes.
https://www.freebsd.org/cgi/man.cgi?query=uuid_create
"must be large enough to hold the 16-octet binary UUID"
There was a problem hiding this comment.
Since @ned-deily wants this fix, I took the liberty of fixing this issue myself.
There was a problem hiding this comment.
Wait. My change only modified the size of the buffer, but not configure, not the call to Py_BuildValue two lines below. I reverted my change.
Anyway, the module constructor has an assertion for sizeof(uuid_t) == 16.
fbfe6bf to
fd869ce
Compare
And now GitHub only shows ... nothing, all these commits and the removal of commits are hidden on this page :-( |
|
@serhiy-storchaka: Sorry, it seems like we worked together on the same branch, your branch :-/ I will no longer touch this branch. I consider that the current code using sizeof(uuid_t) is fine. If you want to use 16, it's up to you. IMHO sizeof(uuid_t) should always be 16, if it's not, we will get a safe Python exception. I prefer to merge the current PR to quickly fix Python 3.7 for the 3.7rc1 release. |
|
Thanks @serhiy-storchaka for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7. |
Use uuid_enc_be() if available to encode UUID to bytes as big endian. (cherry picked from commit 17d8830) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>

An alternate solution using
uuid_enc_be().https://bugs.python.org/issue32493