Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d341500

Browse files
committed
Add 'N' format character to Py_BuildValue -- like 'O' but doesn't INCREF.
Patch and suggestion by Greg Couch.
1 parent 1184789 commit d341500

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Python/modsupport.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ do_mkvalue(p_format, p_va)
332332
return v;
333333
}
334334

335+
case 'N':
335336
case 'S':
336337
case 'O':
337338
if (**p_format == '&') {
@@ -345,7 +346,8 @@ do_mkvalue(p_format, p_va)
345346
PyObject *v;
346347
v = va_arg(*p_va, PyObject *);
347348
if (v != NULL)
348-
Py_INCREF(v);
349+
if (*(*p_format - 1) != 'N')
350+
Py_INCREF(v);
349351
else if (!PyErr_Occurred())
350352
/* If a NULL was passed
351353
* because a call that should

0 commit comments

Comments
 (0)