|
Karsten Hopp |
d5bd53 |
To: vim_dev@googlegroups.com
|
|
Karsten Hopp |
d5bd53 |
Subject: Patch 7.3.1162
|
|
Karsten Hopp |
d5bd53 |
Fcc: outbox
|
|
Karsten Hopp |
d5bd53 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
d5bd53 |
Mime-Version: 1.0
|
|
Karsten Hopp |
d5bd53 |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
d5bd53 |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
d5bd53 |
------------
|
|
Karsten Hopp |
d5bd53 |
|
|
Karsten Hopp |
d5bd53 |
Patch 7.3.1162
|
|
Karsten Hopp |
d5bd53 |
Problem: Python: Memory leaks
|
|
Karsten Hopp |
d5bd53 |
Solution: Add more Py_DECREF(). (ZyX)
|
|
Karsten Hopp |
d5bd53 |
Files: src/if_py_both.h, src/if_python.c
|
|
Karsten Hopp |
d5bd53 |
|
|
Karsten Hopp |
d5bd53 |
|
|
Karsten Hopp |
d5bd53 |
*** ../vim-7.3.1161/src/if_py_both.h 2013-06-10 20:38:58.000000000 +0200
|
|
Karsten Hopp |
d5bd53 |
--- src/if_py_both.h 2013-06-10 20:43:01.000000000 +0200
|
|
Karsten Hopp |
d5bd53 |
***************
|
|
Karsten Hopp |
d5bd53 |
*** 5354,5359 ****
|
|
Karsten Hopp |
d5bd53 |
--- 5354,5360 ----
|
|
Karsten Hopp |
d5bd53 |
{
|
|
Karsten Hopp |
d5bd53 |
int i;
|
|
Karsten Hopp |
d5bd53 |
PyObject *other_module;
|
|
Karsten Hopp |
d5bd53 |
+ PyObject *attr;
|
|
Karsten Hopp |
d5bd53 |
|
|
Karsten Hopp |
d5bd53 |
for (i = 0; i < (int)(sizeof(numeric_constants)
|
|
Karsten Hopp |
d5bd53 |
/ sizeof(struct numeric_constant));
|
|
Karsten Hopp |
d5bd53 |
***************
|
|
Karsten Hopp |
d5bd53 |
*** 5392,5405 ****
|
|
Karsten Hopp |
d5bd53 |
if (!(py_chdir = PyObject_GetAttrString(other_module, "chdir")))
|
|
Karsten Hopp |
d5bd53 |
return -1;
|
|
Karsten Hopp |
d5bd53 |
ADD_OBJECT(m, "_chdir", py_chdir);
|
|
Karsten Hopp |
d5bd53 |
! if (PyObject_SetAttrString(other_module, "chdir", get_attr(m, "chdir")))
|
|
Karsten Hopp |
d5bd53 |
return -1;
|
|
Karsten Hopp |
d5bd53 |
|
|
Karsten Hopp |
d5bd53 |
if ((py_fchdir = PyObject_GetAttrString(other_module, "fchdir")))
|
|
Karsten Hopp |
d5bd53 |
{
|
|
Karsten Hopp |
d5bd53 |
ADD_OBJECT(m, "_fchdir", py_fchdir);
|
|
Karsten Hopp |
d5bd53 |
! if (PyObject_SetAttrString(other_module,"fchdir",get_attr(m,"fchdir")))
|
|
Karsten Hopp |
d5bd53 |
return -1;
|
|
Karsten Hopp |
d5bd53 |
}
|
|
Karsten Hopp |
d5bd53 |
else
|
|
Karsten Hopp |
d5bd53 |
PyErr_Clear();
|
|
Karsten Hopp |
d5bd53 |
--- 5393,5418 ----
|
|
Karsten Hopp |
d5bd53 |
if (!(py_chdir = PyObject_GetAttrString(other_module, "chdir")))
|
|
Karsten Hopp |
d5bd53 |
return -1;
|
|
Karsten Hopp |
d5bd53 |
ADD_OBJECT(m, "_chdir", py_chdir);
|
|
Karsten Hopp |
d5bd53 |
! if (!(attr = get_attr(m, "chdir")))
|
|
Karsten Hopp |
d5bd53 |
return -1;
|
|
Karsten Hopp |
d5bd53 |
+ if (PyObject_SetAttrString(other_module, "chdir", attr))
|
|
Karsten Hopp |
d5bd53 |
+ {
|
|
Karsten Hopp |
d5bd53 |
+ Py_DECREF(attr);
|
|
Karsten Hopp |
d5bd53 |
+ return -1;
|
|
Karsten Hopp |
d5bd53 |
+ }
|
|
Karsten Hopp |
d5bd53 |
+ Py_DECREF(attr);
|
|
Karsten Hopp |
d5bd53 |
|
|
Karsten Hopp |
d5bd53 |
if ((py_fchdir = PyObject_GetAttrString(other_module, "fchdir")))
|
|
Karsten Hopp |
d5bd53 |
{
|
|
Karsten Hopp |
d5bd53 |
ADD_OBJECT(m, "_fchdir", py_fchdir);
|
|
Karsten Hopp |
d5bd53 |
! if (!(attr = get_attr(m, "fchdir")))
|
|
Karsten Hopp |
d5bd53 |
! return -1;
|
|
Karsten Hopp |
d5bd53 |
! if (PyObject_SetAttrString(other_module, "fchdir", attr))
|
|
Karsten Hopp |
d5bd53 |
! {
|
|
Karsten Hopp |
d5bd53 |
! Py_DECREF(attr);
|
|
Karsten Hopp |
d5bd53 |
return -1;
|
|
Karsten Hopp |
d5bd53 |
+ }
|
|
Karsten Hopp |
d5bd53 |
+ Py_DECREF(attr);
|
|
Karsten Hopp |
d5bd53 |
}
|
|
Karsten Hopp |
d5bd53 |
else
|
|
Karsten Hopp |
d5bd53 |
PyErr_Clear();
|
|
Karsten Hopp |
d5bd53 |
*** ../vim-7.3.1161/src/if_python.c 2013-06-10 18:36:20.000000000 +0200
|
|
Karsten Hopp |
d5bd53 |
--- src/if_python.c 2013-06-10 20:42:44.000000000 +0200
|
|
Karsten Hopp |
d5bd53 |
***************
|
|
Karsten Hopp |
d5bd53 |
*** 210,215 ****
|
|
Karsten Hopp |
d5bd53 |
--- 210,216 ----
|
|
Karsten Hopp |
d5bd53 |
# define PyMapping_Check dll_PyMapping_Check
|
|
Karsten Hopp |
d5bd53 |
# define PyIter_Next dll_PyIter_Next
|
|
Karsten Hopp |
d5bd53 |
# define PyModule_GetDict dll_PyModule_GetDict
|
|
Karsten Hopp |
d5bd53 |
+ # define PyModule_AddObject dll_PyModule_AddObject
|
|
Karsten Hopp |
d5bd53 |
# define PyRun_SimpleString dll_PyRun_SimpleString
|
|
Karsten Hopp |
d5bd53 |
# define PyRun_String dll_PyRun_String
|
|
Karsten Hopp |
d5bd53 |
# define PyObject_GetAttrString dll_PyObject_GetAttrString
|
|
Karsten Hopp |
d5bd53 |
***************
|
|
Karsten Hopp |
d5bd53 |
*** 344,349 ****
|
|
Karsten Hopp |
d5bd53 |
--- 345,351 ----
|
|
Karsten Hopp |
d5bd53 |
static int (*dll_PyMapping_Check)(PyObject *);
|
|
Karsten Hopp |
d5bd53 |
static PyObject* (*dll_PyIter_Next)(PyObject *);
|
|
Karsten Hopp |
d5bd53 |
static PyObject*(*dll_PyModule_GetDict)(PyObject *);
|
|
Karsten Hopp |
d5bd53 |
+ static int(*dll_PyModule_AddObject)(PyObject *, const char *, PyObject *);
|
|
Karsten Hopp |
d5bd53 |
static int(*dll_PyRun_SimpleString)(char *);
|
|
Karsten Hopp |
d5bd53 |
static PyObject *(*dll_PyRun_String)(char *, int, PyObject *, PyObject *);
|
|
Karsten Hopp |
d5bd53 |
static PyObject* (*dll_PyObject_GetAttrString)(PyObject *, const char *);
|
|
Karsten Hopp |
d5bd53 |
***************
|
|
Karsten Hopp |
d5bd53 |
*** 509,514 ****
|
|
Karsten Hopp |
d5bd53 |
--- 511,517 ----
|
|
Karsten Hopp |
d5bd53 |
{"PyMapping_Check", (PYTHON_PROC*)&dll_PyMapping_Check},
|
|
Karsten Hopp |
d5bd53 |
{"PyIter_Next", (PYTHON_PROC*)&dll_PyIter_Next},
|
|
Karsten Hopp |
d5bd53 |
{"PyModule_GetDict", (PYTHON_PROC*)&dll_PyModule_GetDict},
|
|
Karsten Hopp |
d5bd53 |
+ {"PyModule_AddObject", (PYTHON_PROC*)&dll_PyModule_AddObject},
|
|
Karsten Hopp |
d5bd53 |
{"PyRun_SimpleString", (PYTHON_PROC*)&dll_PyRun_SimpleString},
|
|
Karsten Hopp |
d5bd53 |
{"PyRun_String", (PYTHON_PROC*)&dll_PyRun_String},
|
|
Karsten Hopp |
d5bd53 |
{"PyObject_GetAttrString", (PYTHON_PROC*)&dll_PyObject_GetAttrString},
|
|
Karsten Hopp |
d5bd53 |
***************
|
|
Karsten Hopp |
d5bd53 |
*** 1357,1375 ****
|
|
Karsten Hopp |
d5bd53 |
#endif
|
|
Karsten Hopp |
d5bd53 |
|
|
Karsten Hopp |
d5bd53 |
static int
|
|
Karsten Hopp |
d5bd53 |
- add_object(PyObject *dict, const char *name, PyObject *object)
|
|
Karsten Hopp |
d5bd53 |
- {
|
|
Karsten Hopp |
d5bd53 |
- if (PyDict_SetItemString(dict, (char *) name, object))
|
|
Karsten Hopp |
d5bd53 |
- return -1;
|
|
Karsten Hopp |
d5bd53 |
- Py_DECREF(object);
|
|
Karsten Hopp |
d5bd53 |
- return 0;
|
|
Karsten Hopp |
d5bd53 |
- }
|
|
Karsten Hopp |
d5bd53 |
-
|
|
Karsten Hopp |
d5bd53 |
- static int
|
|
Karsten Hopp |
d5bd53 |
PythonMod_Init(void)
|
|
Karsten Hopp |
d5bd53 |
{
|
|
Karsten Hopp |
d5bd53 |
PyObject *mod;
|
|
Karsten Hopp |
d5bd53 |
- PyObject *dict;
|
|
Karsten Hopp |
d5bd53 |
|
|
Karsten Hopp |
d5bd53 |
/* The special value is removed from sys.path in Python_Init(). */
|
|
Karsten Hopp |
d5bd53 |
static char *(argv[2]) = {"/must>not&exist/foo", NULL};
|
|
Karsten Hopp |
d5bd53 |
--- 1360,1368 ----
|
|
Karsten Hopp |
d5bd53 |
***************
|
|
Karsten Hopp |
d5bd53 |
*** 1382,1390 ****
|
|
Karsten Hopp |
d5bd53 |
|
|
Karsten Hopp |
d5bd53 |
mod = Py_InitModule4("vim", VimMethods, (char *)NULL, (PyObject *)NULL,
|
|
Karsten Hopp |
d5bd53 |
PYTHON_API_VERSION);
|
|
Karsten Hopp |
d5bd53 |
- dict = PyModule_GetDict(mod);
|
|
Karsten Hopp |
d5bd53 |
|
|
Karsten Hopp |
d5bd53 |
! return populate_module(dict, add_object, PyDict_GetItemString);
|
|
Karsten Hopp |
d5bd53 |
}
|
|
Karsten Hopp |
d5bd53 |
|
|
Karsten Hopp |
d5bd53 |
/*************************************************************************
|
|
Karsten Hopp |
d5bd53 |
--- 1375,1382 ----
|
|
Karsten Hopp |
d5bd53 |
|
|
Karsten Hopp |
d5bd53 |
mod = Py_InitModule4("vim", VimMethods, (char *)NULL, (PyObject *)NULL,
|
|
Karsten Hopp |
d5bd53 |
PYTHON_API_VERSION);
|
|
Karsten Hopp |
d5bd53 |
|
|
Karsten Hopp |
d5bd53 |
! return populate_module(mod, PyModule_AddObject, PyObject_GetAttrString);
|
|
Karsten Hopp |
d5bd53 |
}
|
|
Karsten Hopp |
d5bd53 |
|
|
Karsten Hopp |
d5bd53 |
/*************************************************************************
|
|
Karsten Hopp |
d5bd53 |
*** ../vim-7.3.1161/src/version.c 2013-06-10 20:38:58.000000000 +0200
|
|
Karsten Hopp |
d5bd53 |
--- src/version.c 2013-06-10 20:40:25.000000000 +0200
|
|
Karsten Hopp |
d5bd53 |
***************
|
|
Karsten Hopp |
d5bd53 |
*** 730,731 ****
|
|
Karsten Hopp |
d5bd53 |
--- 730,733 ----
|
|
Karsten Hopp |
d5bd53 |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
d5bd53 |
+ /**/
|
|
Karsten Hopp |
d5bd53 |
+ 1162,
|
|
Karsten Hopp |
d5bd53 |
/**/
|
|
Karsten Hopp |
d5bd53 |
|
|
Karsten Hopp |
d5bd53 |
--
|
|
Karsten Hopp |
d5bd53 |
hundred-and-one symptoms of being an internet addict:
|
|
Karsten Hopp |
d5bd53 |
137. You decide to stay in college for an additional year or two,
|
|
Karsten Hopp |
d5bd53 |
just so you can have the free Internet access.
|
|
Karsten Hopp |
d5bd53 |
|
|
Karsten Hopp |
d5bd53 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
d5bd53 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
d5bd53 |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
Karsten Hopp |
d5bd53 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|