]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add 'N' format character to Py_BuildValue -- like 'O' but doesn't INCREF.
authorGuido van Rossum <guido@python.org>
Wed, 23 Dec 1998 05:01:38 +0000 (05:01 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 23 Dec 1998 05:01:38 +0000 (05:01 +0000)
Patch and suggestion by Greg Couch.

Python/modsupport.c

index 6066aa860e13d17e18980bf9b77d8a7512d1e3da..56bde9e974fc0dd4d5d515fe246e6b07aade4738 100644 (file)
@@ -332,6 +332,7 @@ do_mkvalue(p_format, p_va)
                        return v;
                }
 
+               case 'N':
                case 'S':
                case 'O':
                if (**p_format == '&') {
@@ -345,7 +346,8 @@ do_mkvalue(p_format, p_va)
                        PyObject *v;
                        v = va_arg(*p_va, PyObject *);
                        if (v != NULL)
-                               Py_INCREF(v);
+                               if (*(*p_format - 1) != 'N')
+                                       Py_INCREF(v);
                        else if (!PyErr_Occurred())
                                /* If a NULL was passed
                                 * because a call that should