]> granicus.if.org Git - python/commitdiff
SF bug #733667: kwargs handled incorrectly
authorRaymond Hettinger <python@rcn.com>
Sat, 31 May 2003 07:04:16 +0000 (07:04 +0000)
committerRaymond Hettinger <python@rcn.com>
Sat, 31 May 2003 07:04:16 +0000 (07:04 +0000)
The fast_function() inlining optimization only
applies when there are zero keyword arguments.

Lib/test/test_extcall.py
Python/ceval.c

index d3c2e3f26a0177025c9b8fe3e696da709f002f34..f85baf8e4d8b2a2f8279ebe5aa5aa70efaf8135c 100644 (file)
@@ -1,6 +1,9 @@
 from test.test_support import verify, verbose, TestFailed, sortdict
 from UserList import UserList
 
+def e(a, b):
+    print a, b
+
 def f(*a, **k):
     print a, sortdict(k)
 
@@ -22,6 +25,14 @@ f(1, 2, 3, **{'a':4, 'b':5})
 f(1, 2, 3, *(4, 5), **{'a':6, 'b':7})
 f(1, 2, 3, x=4, y=5, *(6, 7), **{'a':8, 'b':9})
 
+# Verify clearing of SF bug #733667
+try:
+    e(c=3)
+except TypeError:
+    pass
+else:
+    print "should raise TypeError: e() got an unexpected keyword argument 'c'"
+
 try:
     g()
 except TypeError, err:
index 85e9e6b14da8203123677f42a0107f7ae0bcac2c..c652b07b2c3a7b41f8c5e2c865194b04410642a0 100644 (file)
@@ -3468,7 +3468,7 @@ fast_function(PyObject *func, PyObject ***pp_stack, int n, int na, int nk)
 
        PCALL(PCALL_FUNCTION);
        PCALL(PCALL_FAST_FUNCTION);
-       if (argdefs == NULL && co->co_argcount == n && 
+       if (argdefs == NULL && co->co_argcount == n && nk==0 &&
            co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
                PyFrameObject *f;
                PyObject *retval = NULL;