Skip to content

Commit c9b0953

Browse files
committed
python#2964: fix missing INCREF.
1 parent 38feaf0 commit c9b0953

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

‎Misc/NEWS‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ What's new in Python 3.0b1?
1212
Core and Builtins
1313
-----------------
1414

15+
- Issue #2964: fix a missing INCREF in instancemethod_descr_get.
16+
1517
- Issue 2895: Don't crash when given bytes objects as keyword names.
1618

1719
- Issue 2798: When parsing arguments with PyArg_ParseTuple, the "s" code now

‎Objects/classobject.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,10 @@ instancemethod_call(PyObject *self, PyObject *arg, PyObject *kw)
501501
static PyObject *
502502
instancemethod_descr_get(PyObject *descr, PyObject *obj, PyObject *type) {
503503
register PyObject *func = PyInstanceMethod_GET_FUNCTION(descr);
504-
if (obj == NULL)
504+
if (obj == NULL) {
505+
Py_INCREF(func);
505506
return func;
507+
}
506508
else
507509
return PyMethod_New(func, obj);
508510
}

0 commit comments

Comments
 (0)