[pypy-svn] r50943 - pypy/dist/pypy/objspace/test

cfbolz at codespeak.net cfbolz at codespeak.net
Wed Jan 23 19:10:10 CET 2008


Author: cfbolz
Date: Wed Jan 23 19:10:09 2008
New Revision: 50943

Modified:
   pypy/dist/pypy/objspace/test/test_reflective.py
Log:
small improvement to work with functions that have **kwargs


Modified: pypy/dist/pypy/objspace/test/test_reflective.py
==============================================================================
--- pypy/dist/pypy/objspace/test/test_reflective.py	(original)
+++ pypy/dist/pypy/objspace/test/test_reflective.py	Wed Jan 23 19:10:09 2008
@@ -126,21 +126,16 @@
             needed_set = set(needed)
             argnames = set(needed)
             defaults = func.func_defaults
-            has_varargs = bool(code.co_flags & 4)
             for i in range(min(len(args), len(needed))):
                 name = needed[i]
                 needed_set.remove(name)
             for key, value in kwargs.iteritems():
                 if key not in needed_set:
-                    if key not in argnames:
-                        raise TypeError(
-                            "%s() got an unexpected keyword argument %r" % (
-                                func.func_name, key))
-                    else:
+                    if key in argnames:
                         raise TypeError(
                             "%s() got multiple values for keyword argument %r" % (
                                 func.func_name, key))
-                needed_set.remove(key)
+                needed_set.discard(key)
             if defaults is not None:
                 for i in range(len(defaults)):
                     default_name = needed[-1 - i]
@@ -189,3 +184,6 @@
         def f(x, y=1):
             return x + y * 2
         f(y=2)(3) == 7
+        def f(x, **kwds):
+            return x + kwds['y'] * 2
+        f(y=2)(3) == 7



More information about the Pypy-commit mailing list