mirror of
https://github.com/systemd/systemd.git
synced 2024-11-02 19:21:53 +03:00
systemd-python: check for oom, give nicer error messages
This commit is contained in:
parent
c2748ce28c
commit
31f49d022a
@ -75,7 +75,7 @@ static int strv_converter(PyObject* obj, void *_result) {
|
|||||||
assert(result);
|
assert(result);
|
||||||
|
|
||||||
if (!obj)
|
if (!obj)
|
||||||
goto cleanup;
|
return 0;
|
||||||
|
|
||||||
if (obj == Py_None) {
|
if (obj == Py_None) {
|
||||||
*result = NULL;
|
*result = NULL;
|
||||||
@ -87,6 +87,10 @@ static int strv_converter(PyObject* obj, void *_result) {
|
|||||||
|
|
||||||
len = PySequence_Length(obj);
|
len = PySequence_Length(obj);
|
||||||
*result = new0(char*, len + 1);
|
*result = new0(char*, len + 1);
|
||||||
|
if (!*result) {
|
||||||
|
set_error(-ENOMEM, NULL, NULL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
PyObject *item;
|
PyObject *item;
|
||||||
@ -154,7 +158,7 @@ static int Reader_init(Reader *self, PyObject *args, PyObject *keywds)
|
|||||||
char **files = NULL;
|
char **files = NULL;
|
||||||
|
|
||||||
static const char* const kwlist[] = {"flags", "path", "files", NULL};
|
static const char* const kwlist[] = {"flags", "path", "files", NULL};
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, keywds, "|izO&", (char**) kwlist,
|
if (!PyArg_ParseTupleAndKeywords(args, keywds, "|izO&:__init__", (char**) kwlist,
|
||||||
&flags, &path, strv_converter, &files))
|
&flags, &path, strv_converter, &files))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ static int Monitor_init(Monitor *self, PyObject *args, PyObject *keywds)
|
|||||||
int r;
|
int r;
|
||||||
|
|
||||||
static const char* const kwlist[] = {"category", NULL};
|
static const char* const kwlist[] = {"category", NULL};
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, keywds, "|z", (char**) kwlist,
|
if (!PyArg_ParseTupleAndKeywords(args, keywds, "|z:__init__", (char**) kwlist,
|
||||||
&category))
|
&category))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user