summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2018-04-22 19:32:34 +0200
committerChristoph Reiter <reiter.christoph@gmail.com>2018-04-22 21:47:34 +0200
commit2aed3ec87bf48c6043965c82ae1a85e2fb583ff9 (patch)
tree9e10637b999e5121fefbd48489e2d877d9e469d1
parent3e082c1dd0f92662d4558c29f9cafc84ea66cf0c (diff)
downloadpygobject-2aed3ec87bf48c6043965c82ae1a85e2fb583ff9.tar.gz
pypy: avoid calling tp_init, doesn't work with PyPy
Calling tp_init under PyPy does not call the Python level __init__. Filed under https://bitbucket.org/pypy/pypy/issues/2806 Just use PyObject_CallMethod() to call __init__ instead. It works just as well and there is no perf difference from a quick test.
-rw-r--r--gi/gimodule.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/gi/gimodule.c b/gi/gimodule.c
index a3984dad..e46af02c 100644
--- a/gi/gimodule.c
+++ b/gi/gimodule.c
@@ -1030,7 +1030,7 @@ pygobject__g_instance_init(GTypeInstance *instance,
gpointer g_class)
{
GObject *object = (GObject *) instance;
- PyObject *wrapper, *args, *kwargs;
+ PyObject *wrapper, *result;
PyGILState_STATE state;
wrapper = g_object_get_qdata(object, pygobject_wrapper_key);
@@ -1057,18 +1057,16 @@ pygobject__g_instance_init(GTypeInstance *instance,
* so we don't destroy the wrapper. The next call to pygobject_new_full
* will take the ref */
pygobject_ref_float ((PyGObject *) wrapper);
- args = PyTuple_New(0);
- kwargs = PyDict_New();
- if (Py_TYPE(wrapper)->tp_init(wrapper, args, kwargs))
- PyErr_Print();
- Py_DECREF(args);
- Py_DECREF(kwargs);
+ result = PyObject_CallMethod (wrapper, "__init__", NULL);
+ if (result == NULL)
+ PyErr_Print ();
+ else
+ Py_DECREF (result);
}
/* XXX: used for Gtk.Template */
if (PyObject_HasAttrString (wrapper, "__dontuse_ginstance_init__")) {
- PyObject *result;
result = PyObject_CallMethod (wrapper, "__dontuse_ginstance_init__", NULL);
if (result == NULL)
PyErr_Print ();