Staging
v0.5.1
v0.5.1
https://github.com/python/cpython
Revision 1c61f2cc7ab44591b1832307a4022c927502d446 authored by Vinay Sajip on 09 October 2019, 05:48:48 UTC, committed by Ned Deily on 14 October 2019, 21:03:10 UTC
(cherry picked from commit e8bedbddadaa86be6bd86dc32dbdbd53933a4988)
1 parent 918f0c4
Tip revision: 1c61f2cc7ab44591b1832307a4022c927502d446 authored by Vinay Sajip on 09 October 2019, 05:48:48 UTC
bpo-38368: Added fix for ctypes crash when handling arrays in structs/unions. (GH-16589) (GH-16672)
bpo-38368: Added fix for ctypes crash when handling arrays in structs/unions. (GH-16589) (GH-16672)
Tip revision: 1c61f2c
_uuidmodule.c
/*
* Python UUID module that wraps libuuid -
* DCE compatible Universally Unique Identifier library.
*/
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifdef HAVE_UUID_UUID_H
#include <uuid/uuid.h>
#elif defined(HAVE_UUID_H)
#include <uuid.h>
#endif
static PyObject *
py_uuid_generate_time_safe(void)
{
uuid_t uuid;
#ifdef HAVE_UUID_GENERATE_TIME_SAFE
int res;
res = uuid_generate_time_safe(uuid);
return Py_BuildValue("y#i", (const char *) uuid, sizeof(uuid), res);
#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);
#endif
}
static PyMethodDef uuid_methods[] = {
{"generate_time_safe", (PyCFunction) py_uuid_generate_time_safe, METH_NOARGS, NULL},
{NULL, NULL, 0, NULL} /* sentinel */
};
static struct PyModuleDef uuidmodule = {
PyModuleDef_HEAD_INIT,
.m_name = "_uuid",
.m_size = -1,
.m_methods = uuid_methods,
};
PyMODINIT_FUNC
PyInit__uuid(void)
{
PyObject *mod;
assert(sizeof(uuid_t) == 16);
#ifdef HAVE_UUID_GENERATE_TIME_SAFE
int has_uuid_generate_time_safe = 1;
#else
int has_uuid_generate_time_safe = 0;
#endif
mod = PyModule_Create(&uuidmodule);
if (mod == NULL) {
return NULL;
}
if (PyModule_AddIntConstant(mod, "has_uuid_generate_time_safe",
has_uuid_generate_time_safe) < 0) {
Py_DECREF(mod);
return NULL;
}
return mod;
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...