[issue3328] When PyObject_CallMethod fails, refcount is incorrect

Dominic Lavoie report at bugs.python.org
Wed Jul 9 18:48:52 CEST 2008


New submission from Dominic Lavoie <dominic.lavoie at paraxip.com>:

This issue is similar to issue 1229429. In the called Python method, a 
regular expression fails to compile & PyEval_CallMethod() returns 0. 
However, the reference count is incremented by 1 which prevents the 
object from being destroyed.

Could the problem be in classobject.c, in instancemethod_call() ?

		if (newarg == NULL)
			return NULL;
		Py_INCREF(self);
		PyTuple_SET_ITEM(newarg, 0, self);
		for (i = 0; i < argcount; i++) {
			PyObject *v = PyTuple_GET_ITEM(arg, i);
			Py_XINCREF(v);
			PyTuple_SET_ITEM(newarg, i+1, v);
		}
		arg = newarg;
	}
	result = PyObject_Call((PyObject *)func, arg, kw);
	Py_DECREF(arg);
	return result;
}

If result is null, should Py_DECREF(self) be called in the case where 
self was non-null ?

----------
components: Interpreter Core
messages: 69474
nosy: dominic.lavoie
severity: normal
status: open
title: When PyObject_CallMethod fails, refcount is incorrect
type: resource usage
versions: Python 2.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3328>
_______________________________________


More information about the Python-bugs-list mailing list