summaryrefslogtreecommitdiff
path: root/src/if_python3.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2013-05-21 20:51:59 +0200
committerBram Moolenaar <Bram@vim.org>2013-05-21 20:51:59 +0200
commit774267bbb9ac66c89e6e1781c19730a58c772752 (patch)
treeb284bdfe40281a035956ac88f732e7976714da8d /src/if_python3.c
parenta7b64ce74e857d4516b87ca80c850e5ef6324ba6 (diff)
downloadvim-git-774267bbb9ac66c89e6e1781c19730a58c772752.tar.gz
updated for version 7.3.998v7.3.998
Problem: Python: garbage collection issues. Solution: Fix the GC issues: Use proper DESTRUCTOR_FINISH: avoids negative refcounts, use PyObject_GC_* for objects with tp_traverse and tp_clear, add RangeTraverse and RangeClear, use Py_XDECREF in some places. (ZyX)
Diffstat (limited to 'src/if_python3.c')
-rw-r--r--src/if_python3.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/if_python3.c b/src/if_python3.c
index 8a65b67a0..b6507bb77 100644
--- a/src/if_python3.c
+++ b/src/if_python3.c
@@ -213,6 +213,9 @@
# define PyObject_Malloc py3_PyObject_Malloc
# define PyObject_Free py3_PyObject_Free
# endif
+# define _PyObject_GC_New py3__PyObject_GC_New
+# define PyObject_GC_Del py3_PyObject_GC_Del
+# define PyObject_GC_UnTrack py3_PyObject_GC_UnTrack
# define PyType_GenericAlloc py3_PyType_GenericAlloc
# define PyType_GenericNew py3_PyType_GenericNew
# define PyModule_Create2 py3_PyModule_Create2
@@ -334,6 +337,9 @@ static void* (*py3_PyCapsule_GetPointer)(PyObject *, char *);
static void (*py3_PyObject_Free)(void*);
static void* (*py3_PyObject_Malloc)(size_t);
# endif
+static PyObject*(*py3__PyObject_GC_New)(PyTypeObject *);
+static void(*py3_PyObject_GC_Del)(void *);
+static void(*py3_PyObject_GC_UnTrack)(void *);
static int (*py3_PyType_IsSubtype)(PyTypeObject *, PyTypeObject *);
static HINSTANCE hinstPy3 = 0; /* Instance of python.dll */
@@ -463,6 +469,9 @@ static struct
{"PyObject_Malloc", (PYTHON_PROC*)&py3_PyObject_Malloc},
{"PyObject_Free", (PYTHON_PROC*)&py3_PyObject_Free},
# endif
+ {"_PyObject_GC_New", (PYTHON_PROC*)&py3__PyObject_GC_New},
+ {"PyObject_GC_Del", (PYTHON_PROC*)&py3_PyObject_GC_Del},
+ {"PyObject_GC_UnTrack", (PYTHON_PROC*)&py3_PyObject_GC_UnTrack},
{"PyType_IsSubtype", (PYTHON_PROC*)&py3_PyType_IsSubtype},
{"PyCapsule_New", (PYTHON_PROC*)&py3_PyCapsule_New},
{"PyCapsule_GetPointer", (PYTHON_PROC*)&py3_PyCapsule_GetPointer},
@@ -638,7 +647,7 @@ static int py3initialised = 0;
if (bytes != NULL) \
Py_XDECREF(bytes);
-#define DESTRUCTOR_FINISH(self) Py_TYPE(self)->tp_free((PyObject*)self);
+#define DESTRUCTOR_FINISH(self) Py_TYPE(self)->tp_free((PyObject*)self)
#define WIN_PYTHON_REF(win) win->w_python3_ref
#define BUF_PYTHON_REF(buf) buf->b_python3_ref