Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5734f41

Browse filesBrowse files
bpo-32493: Fix uuid.uuid1() on FreeBSD. (GH-7099)
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>
1 parent d9eb22c commit 5734f41
Copy full SHA for 5734f41

File tree

Expand file treeCollapse file tree

5 files changed

+61
-1
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+61
-1
lines changed
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed :func:`uuid.uuid1` on FreeBSD.

‎Modules/_uuidmodule.c

Copy file name to clipboardExpand all lines: Modules/_uuidmodule.c
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,16 @@ py_uuid_generate_time_safe(void)
1818

1919
res = uuid_generate_time_safe(uuid);
2020
return Py_BuildValue("y#i", (const char *) uuid, sizeof(uuid), res);
21-
#elif HAVE_UUID_CREATE
21+
#elif defined(HAVE_UUID_CREATE)
2222
uint32_t status;
2323
uuid_create(&uuid, &status);
24+
# if defined(HAVE_UUID_ENC_BE)
25+
unsigned char buf[sizeof(uuid)];
26+
uuid_enc_be(buf, &uuid);
27+
return Py_BuildValue("y#i", buf, sizeof(uuid), (int) status);
28+
# else
2429
return Py_BuildValue("y#i", (const char *) &uuid, sizeof(uuid), (int) status);
30+
# endif
2531
#else
2632
uuid_generate_time(uuid);
2733
return Py_BuildValue("y#O", (const char *) uuid, sizeof(uuid), Py_None);
@@ -57,6 +63,7 @@ PyInit__uuid(void)
5763
}
5864
if (PyModule_AddIntConstant(mod, "has_uuid_generate_time_safe",
5965
has_uuid_generate_time_safe) < 0) {
66+
Py_DECREF(mod);
6067
return NULL;
6168
}
6269

‎configure

Copy file name to clipboardExpand all lines: configure
+34Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9625,6 +9625,40 @@ $as_echo "no" >&6; }
96259625
fi
96269626
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
96279627

9628+
# Little-endian FreeBSD, OpenBSD and NetBSD needs encoding into an octet
9629+
# stream in big-endian byte-order
9630+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_enc_be" >&5
9631+
$as_echo_n "checking for uuid_enc_be... " >&6; }
9632+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
9633+
/* end confdefs.h. */
9634+
#include <uuid.h>
9635+
int
9636+
main ()
9637+
{
9638+
9639+
#ifndef uuid_enc_be
9640+
uuid_t uuid;
9641+
unsigned char buf[sizeof(uuid)];
9642+
uuid_enc_be(buf, &uuid);
9643+
#endif
9644+
9645+
;
9646+
return 0;
9647+
}
9648+
_ACEOF
9649+
if ac_fn_c_try_compile "$LINENO"; then :
9650+
9651+
$as_echo "#define HAVE_UUID_ENC_BE 1" >>confdefs.h
9652+
9653+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
9654+
$as_echo "yes" >&6; }
9655+
else
9656+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
9657+
$as_echo "no" >&6; }
9658+
9659+
fi
9660+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
9661+
96289662
# 'Real Time' functions on Solaris
96299663
# posix4 on Solaris 2.6
96309664
# pthread (first!) on Linux

‎configure.ac

Copy file name to clipboardExpand all lines: configure.ac
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2742,6 +2742,21 @@ void *x = uuid_create
27422742
[AC_MSG_RESULT(no)]
27432743
)
27442744

2745+
# Little-endian FreeBSD, OpenBSD and NetBSD needs encoding into an octet
2746+
# stream in big-endian byte-order
2747+
AC_MSG_CHECKING(for uuid_enc_be)
2748+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <uuid.h>]], [[
2749+
#ifndef uuid_enc_be
2750+
uuid_t uuid;
2751+
unsigned char buf[sizeof(uuid)];
2752+
uuid_enc_be(buf, &uuid);
2753+
#endif
2754+
]])],
2755+
[AC_DEFINE(HAVE_UUID_ENC_BE, 1, Define if uuid_enc_be() exists.)
2756+
AC_MSG_RESULT(yes)],
2757+
[AC_MSG_RESULT(no)]
2758+
)
2759+
27452760
# 'Real Time' functions on Solaris
27462761
# posix4 on Solaris 2.6
27472762
# pthread (first!) on Linux

‎pyconfig.h.in

Copy file name to clipboardExpand all lines: pyconfig.h.in
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,9 @@
12121212
/* Define if uuid_create() exists. */
12131213
#undef HAVE_UUID_CREATE
12141214

1215+
/* Define if uuid_enc_be() exists. */
1216+
#undef HAVE_UUID_ENC_BE
1217+
12151218
/* Define if uuid_generate_time_safe() exists. */
12161219
#undef HAVE_UUID_GENERATE_TIME_SAFE
12171220

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.