[lxc-devel] [lxc/master] Fixed python-lxc reference to var before assignment

ar45 on Github lxc-bot at linuxcontainers.org
Thu Apr 14 04:25:54 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 718 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160414/ab60b835/attachment.bin>
-------------- next part --------------
From 9cee41def4bbaddc089ea02f85b2ed028ac5a549 Mon Sep 17 00:00:00 2001
From: Aron Podrigal <aronp at guaranteedplus.com>
Date: Thu, 14 Apr 2016 00:21:08 -0400
Subject: [PATCH] Fixed python-lxc reference to var before assignment

```
>>> c = lxc.Container('ct')
>>> c.create('debian', args=('-r', 'jessie'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/lxc/__init__.py", line 229, in
create
    template_args['args'] = tuple(tmp_args)
UnboundLocalError: local variable 'tmp_args' referenced before
assignment
```

Signed-off-by: Aron Podrigal <aronp at guaranteedplus.com>
---
 src/python-lxc/lxc/__init__.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/python-lxc/lxc/__init__.py b/src/python-lxc/lxc/__init__.py
index 30ebd1b..de02102 100644
--- a/src/python-lxc/lxc/__init__.py
+++ b/src/python-lxc/lxc/__init__.py
@@ -222,11 +222,12 @@ def create(self, template=None, flags=0, args=(), bdevtype=None):
             for item in args.items():
                 tmp_args.append("--%s" % item[0])
                 tmp_args.append("%s" % item[1])
+            args = tmp_args
         template_args = {}
         if template:
     	    template_args['template'] = template
         template_args['flags'] = flags
-        template_args['args'] = tuple(tmp_args)
+        template_args['args'] = tuple(args)
         if bdevtype:
             template_args['bdevtype'] = bdevtype
         return _lxc.Container.create(self, **template_args)


More information about the lxc-devel mailing list