chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
systemd-stdio-bridge: make it socket-activatable and usable as kdbus bridge
[elogind.git]
/
src
/
python-systemd
/
id128.c
diff --git
a/src/python-systemd/id128.c
b/src/python-systemd/id128.c
index 04db786b66dc649c359ee9cfd1d776d2b3e5e5aa..ec1d9fb4a2b530d6d7929bd0cf07356c40219108 100644
(file)
--- a/
src/python-systemd/id128.c
+++ b/
src/python-systemd/id128.c
@@
-23,14
+23,7
@@
#include <systemd/sd-messages.h>
#include <systemd/sd-messages.h>
-#define _cleanup_Py_DECREF_ __attribute__((cleanup(cleanup_Py_DECREFp)))
-
-static void cleanup_Py_DECREFp(PyObject **p) {
- if (!*p)
- return;
-
- Py_DECREF(*p);
-}
+#include "pyutil.h"
PyDoc_STRVAR(module__doc__,
"Python interface to the libsystemd-id128 library.\n\n"
PyDoc_STRVAR(module__doc__,
"Python interface to the libsystemd-id128 library.\n\n"
@@
-57,9
+50,9
@@
PyDoc_STRVAR(get_boot__doc__,
);
static PyObject* make_uuid(sd_id128_t id) {
);
static PyObject* make_uuid(sd_id128_t id) {
- PyObject _cleanup_Py_DECREF_
+ _cleanup_Py_DECREF_ PyObject
*uuid = NULL, *UUID = NULL, *bytes = NULL,
*uuid = NULL, *UUID = NULL, *bytes = NULL,
- *args = NULL, *kwargs = NULL
, *obj = NULL
;
+ *args = NULL, *kwargs = NULL;
uuid = PyImport_ImportModule("uuid");
if (!uuid)
uuid = PyImport_ImportModule("uuid");
if (!uuid)
@@
-106,13
+99,13
@@
static PyMethodDef methods[] = {
};
static int add_id(PyObject *module, const char* name, sd_id128_t id) {
};
static int add_id(PyObject *module, const char* name, sd_id128_t id) {
- PyObject
_cleanup_Py_DECREF_
*obj;
+ PyObject *obj;
obj = make_uuid(id);
if (!obj)
return -1;
obj = make_uuid(id);
if (!obj)
return -1;
- return Py
Object_SetAttrString
(module, name, obj);
+ return Py
Module_AddObject
(module, name, obj);
}
#pragma GCC diagnostic push
}
#pragma GCC diagnostic push
@@
-127,7
+120,11
@@
PyMODINIT_FUNC initid128(void) {
if (m == NULL)
return;
if (m == NULL)
return;
+ /* a series of lines like 'add_id() ;' follow */
+#define JOINER ;
#include "id128-constants.h"
#include "id128-constants.h"
+#undef JOINER
+ PyModule_AddStringConstant(m, "__version__", PACKAGE_VERSION);
}
#else
}
#else
@@
-136,7
+133,7
@@
static struct PyModuleDef module = {
PyModuleDef_HEAD_INIT,
"id128", /* name of module */
module__doc__, /* module documentation, may be NULL */
PyModuleDef_HEAD_INIT,
"id128", /* name of module */
module__doc__, /* module documentation, may be NULL */
-
0
, /* size of per-interpreter state of the module */
+
-1
, /* size of per-interpreter state of the module */
methods
};
methods
};
@@
-147,7
+144,14
@@
PyMODINIT_FUNC PyInit_id128(void) {
if (m == NULL)
return NULL;
if (m == NULL)
return NULL;
+ if ( /* a series of lines like 'add_id() ||' follow */
+#define JOINER ||
#include "id128-constants.h"
#include "id128-constants.h"
+#undef JOINER
+ PyModule_AddStringConstant(m, "__version__", PACKAGE_VERSION)) {
+ Py_DECREF(m);
+ return NULL;
+ }
return m;
}
return m;
}