summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-05-24 22:45:09 (GMT)
committerVictor Stinner <vstinner@redhat.com>2018-05-24 22:45:09 (GMT)
commit17d8830312d82e7de42ab89739b0771f712645ff (patch)
tree6d87adc3ad89f6e3ac2d5eec511216fafaeab566 /Modules
parent483000e164ec68717d335767b223ae31b4b720cf (diff)
downloadcpython-17d8830312d82e7de42ab89739b0771f712645ff.zip
cpython-17d8830312d82e7de42ab89739b0771f712645ff.tar.gz
cpython-17d8830312d82e7de42ab89739b0771f712645ff.tar.bz2
bpo-32493: Fix uuid.uuid1() on FreeBSD. (GH-7099)
Use uuid_enc_be() if available to encode UUID to bytes as big endian.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_uuidmodule.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/Modules/_uuidmodule.c b/Modules/_uuidmodule.c
index 3a0c057..0b7f2a2 100644
--- a/Modules/_uuidmodule.c
+++ b/Modules/_uuidmodule.c
@@ -19,10 +19,16 @@ py_uuid_generate_time_safe(PyObject *Py_UNUSED(context),
res = uuid_generate_time_safe(uuid);
return Py_BuildValue("y#i", (const char *) uuid, sizeof(uuid), res);
-#elif HAVE_UUID_CREATE
+#elif defined(HAVE_UUID_CREATE)
uint32_t status;
uuid_create(&uuid, &status);
+# if defined(HAVE_UUID_ENC_BE)
+ unsigned char buf[sizeof(uuid)];
+ uuid_enc_be(buf, &uuid);
+ return Py_BuildValue("y#i", buf, sizeof(uuid), (int) status);
+# else
return Py_BuildValue("y#i", (const char *) &uuid, sizeof(uuid), (int) status);
+# endif
#else
uuid_generate_time(uuid);
return Py_BuildValue("y#O", (const char *) uuid, sizeof(uuid), Py_None);
@@ -58,6 +64,7 @@ PyInit__uuid(void)
}
if (PyModule_AddIntConstant(mod, "has_uuid_generate_time_safe",
has_uuid_generate_time_safe) < 0) {
+ Py_DECREF(mod);
return NULL;
}