From f14f0a8f20300e58a8223edadb354bec60278dac Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Sun, 23 Aug 2009 19:16:26 +0100 Subject: [PATCH] mem fixes --- pybindgen/cppexception.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pybindgen/cppexception.py b/pybindgen/cppexception.py index 9d6c2dc..edfe852 100644 --- a/pybindgen/cppexception.py +++ b/pybindgen/cppexception.py @@ -101,9 +101,11 @@ class CppException(object): if self.outer_class is None: module.after_init.write_code( - 'PyModule_AddObject(m, (char *) \"%s\", (PyObject *) &%s);' % ( - self.python_name, self.pytypestruct)) + 'Py_INCREF((PyObject *) %s);\n' + 'PyModule_AddObject(m, (char *) \"%s\", (PyObject *) %s);' % ( + self.pytypestruct, self.python_name, self.pytypestruct)) else: module.after_init.write_code( - 'PyDict_SetItemString((PyObject*) %s.tp_dict, (char *) \"%s\", (PyObject *) &%s);' % ( - self.outer_class.pytypestruct, self.python_name, self.pytypestruct)) + 'Py_INCREF((PyObject *) %s);\n' + 'PyDict_SetItemString((PyObject*) %s.tp_dict, (char *) \"%s\", (PyObject *) %s);' % ( + self.pytypestruct, self.outer_class.pytypestruct, self.python_name, self.pytypestruct))