[pygobject] object: try to avoid calling PyObject_ClearWeakRefs()
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] object: try to avoid calling PyObject_ClearWeakRefs()
- Date: Sun, 25 Mar 2018 14:21:46 +0000 (UTC)
commit be895cafdb7197c92f428a40b4599f9af38cde28
Author: Christoph Reiter <reiter christoph gmail com>
Date: Sun Mar 25 16:12:45 2018 +0200
object: try to avoid calling PyObject_ClearWeakRefs()
We only need to call PyObject_ClearWeakRefs if the weakref list is set.
And since PyPy doesn't like PyObject_ClearWeakRefs this makes it work
in the common case.
gi/pygobject-object.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/gi/pygobject-object.c b/gi/pygobject-object.c
index 3c5e7af0..0bfeacc2 100644
--- a/gi/pygobject-object.c
+++ b/gi/pygobject-object.c
@@ -1084,7 +1084,9 @@ pygobject_dealloc(PyGObject *self)
* object. */
PyObject_GC_UnTrack((PyObject *)self);
- PyObject_ClearWeakRefs((PyObject *)self);
+ if (self->weakreflist != NULL)
+ PyObject_ClearWeakRefs((PyObject *)self);
+
/* this forces inst_data->type to be updated, which could prove
* important if a new wrapper has to be created and it is of a
* unregistered type */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]