[pypy-commit] pypy virtual-arguments: reshuffle logic to make it clearer

cfbolz noreply at buildbot.pypy.org
Mon Apr 16 11:46:32 CEST 2012


Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: virtual-arguments
Changeset: r54394:b86443b52757
Date: 2012-04-14 11:05 +0200
http://bitbucket.org/pypy/pypy/changeset/b86443b52757/

Log:	reshuffle logic to make it clearer

diff --git a/pypy/interpreter/argument.py b/pypy/interpreter/argument.py
--- a/pypy/interpreter/argument.py
+++ b/pypy/interpreter/argument.py
@@ -316,6 +316,23 @@
                     signature, blindargs, input_argcount, keywords,
                     keywords_w, scope_w, used_keywords,
                     self._dont_jit)
+        if has_kwarg:
+            w_kwds = self.space.newdict(kwargs=True)
+            # collect extra keyword arguments into the **kwarg
+            if num_remainingkwds:
+                _collect_keyword_args(
+                        self.space, keywords, keywords_w, w_kwds,
+                        used_keywords, self.keyword_names_w, self._dont_jit)
+                #
+            scope_w[co_argcount + has_vararg] = w_kwds
+        elif num_remainingkwds:
+            if co_argcount == 0:
+                raise ArgErrCount(avail, num_kwds,
+                              co_argcount, has_vararg, has_kwarg,
+                              defaults_w, 0)
+            raise ArgErrUnknownKwds(self.space, num_remainingkwds, keywords,
+                                    used_keywords, self.keyword_names_w)
+
         missing = 0
         if input_argcount < co_argcount:
             def_first = co_argcount - (0 if defaults_w is None else len(defaults_w))
@@ -330,28 +347,10 @@
                     # because it might be related to a problem with */** or
                     # keyword arguments, which will be checked for below.
                     missing += 1
-
-        if has_kwarg:
-            w_kwds = self.space.newdict(kwargs=True)
-            # collect extra keyword arguments into the **kwarg
-            if num_remainingkwds:
-                _collect_keyword_args(
-                        self.space, keywords, keywords_w, w_kwds,
-                        used_keywords, self.keyword_names_w, self._dont_jit)
-                #
-            scope_w[co_argcount + has_vararg] = w_kwds
-        elif num_remainingkwds:
-            if co_argcount == 0:
+            if missing:
                 raise ArgErrCount(avail, num_kwds,
-                              co_argcount, has_vararg, has_kwarg,
-                              defaults_w, missing)
-            raise ArgErrUnknownKwds(self.space, num_remainingkwds, keywords,
-                                    used_keywords, self.keyword_names_w)
-
-        if missing:
-            raise ArgErrCount(avail, num_kwds,
-                              co_argcount, has_vararg, has_kwarg,
-                              defaults_w, missing)
+                                  co_argcount, has_vararg, has_kwarg,
+                                  defaults_w, missing)
 
         return co_argcount + has_vararg + has_kwarg
 


More information about the pypy-commit mailing list