comparison src/if_py_both.h @ 4831:b8eabb6a9687 v7.3.1162

updated for version 7.3.1162 Problem: Python: Memory leaks Solution: Add more Py_DECREF(). (ZyX)
author Bram Moolenaar <bram@vim.org>
date Mon, 10 Jun 2013 20:47:36 +0200
parents ff3935926449
children 70b1178dec79
comparison
equal deleted inserted replaced
4830:46f46b5adc5a 4831:b8eabb6a9687
5352 static int 5352 static int
5353 populate_module(PyObject *m, object_adder add_object, attr_getter get_attr) 5353 populate_module(PyObject *m, object_adder add_object, attr_getter get_attr)
5354 { 5354 {
5355 int i; 5355 int i;
5356 PyObject *other_module; 5356 PyObject *other_module;
5357 PyObject *attr;
5357 5358
5358 for (i = 0; i < (int)(sizeof(numeric_constants) 5359 for (i = 0; i < (int)(sizeof(numeric_constants)
5359 / sizeof(struct numeric_constant)); 5360 / sizeof(struct numeric_constant));
5360 ++i) 5361 ++i)
5361 ADD_CHECKED_OBJECT(m, numeric_constants[i].name, 5362 ADD_CHECKED_OBJECT(m, numeric_constants[i].name,
5390 ADD_OBJECT(m, "_getcwd", py_getcwd) 5391 ADD_OBJECT(m, "_getcwd", py_getcwd)
5391 5392
5392 if (!(py_chdir = PyObject_GetAttrString(other_module, "chdir"))) 5393 if (!(py_chdir = PyObject_GetAttrString(other_module, "chdir")))
5393 return -1; 5394 return -1;
5394 ADD_OBJECT(m, "_chdir", py_chdir); 5395 ADD_OBJECT(m, "_chdir", py_chdir);
5395 if (PyObject_SetAttrString(other_module, "chdir", get_attr(m, "chdir"))) 5396 if (!(attr = get_attr(m, "chdir")))
5396 return -1; 5397 return -1;
5398 if (PyObject_SetAttrString(other_module, "chdir", attr))
5399 {
5400 Py_DECREF(attr);
5401 return -1;
5402 }
5403 Py_DECREF(attr);
5397 5404
5398 if ((py_fchdir = PyObject_GetAttrString(other_module, "fchdir"))) 5405 if ((py_fchdir = PyObject_GetAttrString(other_module, "fchdir")))
5399 { 5406 {
5400 ADD_OBJECT(m, "_fchdir", py_fchdir); 5407 ADD_OBJECT(m, "_fchdir", py_fchdir);
5401 if (PyObject_SetAttrString(other_module,"fchdir",get_attr(m,"fchdir"))) 5408 if (!(attr = get_attr(m, "fchdir")))
5402 return -1; 5409 return -1;
5410 if (PyObject_SetAttrString(other_module, "fchdir", attr))
5411 {
5412 Py_DECREF(attr);
5413 return -1;
5414 }
5415 Py_DECREF(attr);
5403 } 5416 }
5404 else 5417 else
5405 PyErr_Clear(); 5418 PyErr_Clear();
5406 5419
5407 return 0; 5420 return 0;