]> granicus.if.org Git - python/commitdiff
Use int 0 as default defval for LCID if nothing has been supplied.
authorThomas Heller <theller@ctypes.org>
Thu, 16 Mar 2006 19:56:24 +0000 (19:56 +0000)
committerThomas Heller <theller@ctypes.org>
Thu, 16 Mar 2006 19:56:24 +0000 (19:56 +0000)
Modules/_ctypes/_ctypes.c

index 6ee815c9559385d65512703cf4fa3503f6584107..604c590db77cfeda5b51f6ec7f20bc2fc844f96f 100644 (file)
@@ -2840,9 +2840,14 @@ _build_callargs(CFuncPtrObject *self, PyObject *argtypes,
 
                switch (flag & (PARAMFLAG_FIN | PARAMFLAG_FOUT | PARAMFLAG_FLCID)) {
                case PARAMFLAG_FIN | PARAMFLAG_FLCID:
-                       /* ['in', 'lcid'] parameter.  Always taken from defval */
-                       assert(defval);
-                       Py_INCREF(defval);
+                       /* ['in', 'lcid'] parameter.  Always taken from defval,
+                        if given, else the integer 0. */
+                       if (defval == NULL) {
+                               defval = PyInt_FromLong(0);
+                               if (defval == NULL)
+                                       goto error;
+                       } else
+                               Py_INCREF(defval);
                        PyTuple_SET_ITEM(callargs, i, defval);
                        break;
                case (PARAMFLAG_FIN | PARAMFLAG_FOUT):