Author: amaury.forgeotdarc
Date: Sat Nov 24 01:29:24 2007
New Revision: 59155

Modified:
   python/branches/py3k/Lib/test/test_scope.py
   python/branches/py3k/Python/ceval.c
Log:
fix #1409: cell variables were not initialized,
when the value comes from a keyword-only parameter.


Modified: python/branches/py3k/Lib/test/test_scope.py
==============================================================================
--- python/branches/py3k/Lib/test/test_scope.py (original)
+++ python/branches/py3k/Lib/test/test_scope.py Sat Nov 24 01:29:24 2007
@@ -166,6 +166,17 @@
         self.assertEqual(t.method_and_var(), "method")
         self.assertEqual(t.actual_global(), "global")
 
+    def testCellIsKwonlyArg(self):
+        # Issue 1409: Initialisation of a cell value,
+        # when it comes from a keyword-only parameter
+        def foo(*, a=17):
+            def bar():
+                return a + 5
+            return bar() + 3
+
+        self.assertEqual(foo(a=42), 50)
+        self.assertEqual(foo(), 25)
+
     def testRecursion(self):
 
         def f(x):

Modified: python/branches/py3k/Python/ceval.c
==============================================================================
--- python/branches/py3k/Python/ceval.c (original)
+++ python/branches/py3k/Python/ceval.c Sat Nov 24 01:29:24 2007
@@ -2708,7 +2708,7 @@
                Py_UNICODE *cellname, *argname;
                PyObject *c;
 
-               nargs = co->co_argcount;
+               nargs = co->co_argcount + co->co_kwonlyargcount;
                if (co->co_flags & CO_VARARGS)
                        nargs++;
                if (co->co_flags & CO_VARKEYWORDS)
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to