2
0
mirror of git://github.com/lxc/lxc synced 2025-08-31 15:47:54 +00:00

python3: Handle invalid global config keys

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
Stéphane Graber
2014-05-25 16:33:37 +02:00
parent 8df68465f2
commit 1b03969c7c

View File

@@ -329,12 +329,20 @@ LXC_get_global_config_item(PyObject *self, PyObject *args, PyObject *kwds)
{
static char *kwlist[] = {"key", NULL};
char* key = NULL;
const char* value = NULL;
if (! PyArg_ParseTupleAndKeywords(args, kwds, "s|", kwlist,
&key))
return NULL;
return PyUnicode_FromString(lxc_get_global_config_item(key));
value = lxc_get_global_config_item(key);
if (!value) {
PyErr_SetString(PyExc_KeyError, "Invalid configuration key");
return NULL;
}
return PyUnicode_FromString(value);
}
static PyObject *