]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
empty kw dict is ok for builtins
authorGuido van Rossum <guido@python.org>
Fri, 4 Aug 1995 04:14:47 +0000 (04:14 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 4 Aug 1995 04:14:47 +0000 (04:14 +0000)
Python/ceval.c

index a0431aa12fff6ffd17aa0974f5ff05cd2d6a4ed1..d725d3566497df85325a10c5ea77d1402e679912 100644 (file)
@@ -2281,6 +2281,11 @@ PyEval_CallObjectWithKeywords(func, arg, kw)
        else
                INCREF(arg);
 
+       if (kw != NULL && !is_dictobject(kw)) {
+               err_setstr(TypeError, "keyword list must be a dictionary");
+               return NULL;
+       }
+
         if (call = func->ob_type->tp_call)
                 result = (*call)(func, arg, kw);
         else if (is_instancemethodobject(func) || is_funcobject(func))
@@ -2316,7 +2321,7 @@ call_builtin(func, arg, kw)
                }
                if (flags & METH_KEYWORDS)
                        return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
-               if (kw != NULL) {
+               if (kw != NULL && getmappingsize(kw) != 0) {
                        err_setstr(TypeError,
                                   "this function takes no keyword arguments");
                        return NULL;