From 9dfb0ad9bedb456ce618a7e690103545f6d030b1 Mon Sep 17 00:00:00 2001 From: Aron Podrigal Date: Sun, 1 May 2016 11:06:53 -0400 Subject: [PATCH] Fixed - set PyErr when Container.__init__ fails 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 --- src/python-lxc/lxc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/python-lxc/lxc.c b/src/python-lxc/lxc.c index 151d8faa1..4f637d09b 100644 --- a/src/python-lxc/lxc.c +++ b/src/python-lxc/lxc.c @@ -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; } -- 2.47.2