]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Fixed - set PyErr when Container.__init__ fails
authorAron Podrigal <aronp@guaranteedplus.com>
Sun, 1 May 2016 15:06:53 +0000 (11:06 -0400)
committerStéphane Graber <stgraber@ubuntu.com>
Thu, 17 Nov 2016 23:20:09 +0000 (18:20 -0500)
When container init failed for whatever reason, previously it resulted
in a `SystemError: NULL result without error in PyObject_Call`
This will now result in a RuntimeError with the error message
previously printed to stderr.

Signed-off-by: Aron Podrigal <aronp@guaranteedplus.com>
src/python-lxc/lxc.c

index b45ff7b97574de5ada39ef6472f938211f65c6a7..cc7ad447b43b759f393fe0531a81bb008c473f43 100644 (file)
@@ -449,7 +449,9 @@ Container_init(Container *self, PyObject *args, PyObject *kwds)
     self->container = lxc_container_new(name, config_path);
     if (!self->container) {
         Py_XDECREF(fs_config_path);
-        fprintf(stderr, "%d: error creating container %s\n", __LINE__, name);
+
+        PyErr_Format(PyExc_RuntimeError, "%s:%s:%d: error during init for container '%s'.",
+                       __FUNCTION__, __FILE__, __LINE__, name);
         return -1;
     }