Author: Carl Friedrich Bolz <cfb...@gmx.de> Branch: virtual-arguments Changeset: r54393:a3a1be50ae8e Date: 2012-04-14 10:50 +0200 http://bitbucket.org/pypy/pypy/changeset/a3a1be50ae8e/
Log: move another function that could force the Arguments instance to the global level diff --git a/pypy/interpreter/argument.py b/pypy/interpreter/argument.py --- a/pypy/interpreter/argument.py +++ b/pypy/interpreter/argument.py @@ -199,43 +199,17 @@ "a mapping, not %s" % (typename,))) raise keys_w = space.unpackiterable(w_keys) - self._do_combine_starstarargs_wrapped(keys_w, w_starstararg) - return True - - def _do_combine_starstarargs_wrapped(self, keys_w, w_starstararg): - space = self.space keywords_w = [None] * len(keys_w) keywords = [None] * len(keys_w) - i = 0 - for w_key in keys_w: - try: - key = space.str_w(w_key) - except OperationError, e: - if e.match(space, space.w_TypeError): - raise OperationError( - space.w_TypeError, - space.wrap("keywords must be strings")) - if e.match(space, space.w_UnicodeEncodeError): - # Allow this to pass through - key = None - else: - raise - else: - if self.keywords and key in self.keywords: - raise operationerrfmt(self.space.w_TypeError, - "got multiple values " - "for keyword argument " - "'%s'", key) - keywords[i] = key - keywords_w[i] = space.getitem(w_starstararg, w_key) - i += 1 + _do_combine_starstarargs_wrapped(space, keys_w, w_starstararg, keywords, keywords_w, self.keywords) + self.keyword_names_w = keys_w if self.keywords is None: self.keywords = keywords self.keywords_w = keywords_w else: self.keywords = self.keywords + keywords self.keywords_w = self.keywords_w + keywords_w - self.keyword_names_w = keys_w + return True def fixedunpack(self, argcount): @@ -461,6 +435,32 @@ "for keyword argument " "'%s'", key) +def _do_combine_starstarargs_wrapped(space, keys_w, w_starstararg, keywords, + keywords_w, existingkeywords): + i = 0 + for w_key in keys_w: + try: + key = space.str_w(w_key) + except OperationError, e: + if e.match(space, space.w_TypeError): + raise OperationError( + space.w_TypeError, + space.wrap("keywords must be strings")) + if e.match(space, space.w_UnicodeEncodeError): + # Allow this to pass through + key = None + else: + raise + else: + if existingkeywords and key in existingkeywords: + raise operationerrfmt(space.w_TypeError, + "got multiple values " + "for keyword argument " + "'%s'", key) + keywords[i] = key + keywords_w[i] = space.getitem(w_starstararg, w_key) + i += 1 + @jit.look_inside_iff( lambda signature, blindargs, input_argcount, keywords, keywords_w, scope_w, used_keywords, jitoff: not jitoff) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit