mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-25 09:51:52 +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:
parent
8df68465f2
commit
1b03969c7c
@ -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 *
|
||||
|
Loading…
Reference in New Issue
Block a user