[lxc-devel] [lxc/master] Fixed - set PyErr when Container.__init__ fails

ar45 on Github lxc-bot at linuxcontainers.org
Sun May 1 15:41:11 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 885 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160501/9d39f591/attachment.bin>
-------------- next part --------------
From 9dfb0ad9bedb456ce618a7e690103545f6d030b1 Mon Sep 17 00:00:00 2001
From: Aron Podrigal <aronp at guaranteedplus.com>
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 <aronp at guaranteedplus.com>
---
 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 151d8fa..4f637d0 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;
     }
 


More information about the lxc-devel mailing list