aboutsummaryrefslogtreecommitdiffstats
path: root/tools/python/genwrap.py
diff options
context:
space:
mode:
authorGianni Tedesco <gianni.tedesco@citrix.com>2011-01-11 18:54:44 +0000
committerGianni Tedesco <gianni.tedesco@citrix.com>2011-01-11 18:54:44 +0000
commit5644ab84f714d6e248979e3800b2d48a43be0eaf (patch)
treefa39a6305de72872c23b4e28b4b29fa2247f3631 /tools/python/genwrap.py
parentbdf80c61cb1f705c0f4472cbd7694c99bca9b0c5 (diff)
downloadxen-5644ab84f714d6e248979e3800b2d48a43be0eaf.tar.gz
xen-5644ab84f714d6e248979e3800b2d48a43be0eaf.tar.bz2
xen-5644ab84f714d6e248979e3800b2d48a43be0eaf.zip
tools/python/pyxl: Fix reference counting of Py_(None|True|False)
The incorrect refcounting causes the python interpreter to crash Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/python/genwrap.py')
-rw-r--r--tools/python/genwrap.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/python/genwrap.py b/tools/python/genwrap.py
index 7875d46522..fd2d39dd6e 100644
--- a/tools/python/genwrap.py
+++ b/tools/python/genwrap.py
@@ -51,7 +51,10 @@ def py_attrib_get(ty, f):
l.append('static PyObject *py_%s_%s_get(Py_%s *self, void *priv)'%(ty.rawname, f.name, ty.rawname))
l.append('{')
if t == TYPE_BOOL:
- l.append(' return (self->obj.%s) ? Py_True : Py_False;'%f.name)
+ l.append(' PyObject *ret;')
+ l.append(' ret = (self->obj.%s) ? Py_True : Py_False;'%f.name)
+ l.append(' Py_INCREF(ret);')
+ l.append(' return ret;')
elif t == TYPE_INT:
l.append(' return genwrap__ll_get(self->obj.%s);'%f.name)
elif t == TYPE_UINT: