Author: Carl Friedrich Bolz <cfb...@gmx.de> Branch: virtual-arguments Changeset: r54407:1df3aae4ac9f Date: 2012-04-14 14:55 +0200 http://bitbucket.org/pypy/pypy/changeset/1df3aae4ac9f/
Log: make the result of view_as_kwargs not resizable diff --git a/pypy/interpreter/argument.py b/pypy/interpreter/argument.py --- a/pypy/interpreter/argument.py +++ b/pypy/interpreter/argument.py @@ -174,8 +174,8 @@ keywords, values_w = space.view_as_kwargs(w_starstararg) if keywords is not None: # this path also taken for empty dicts if self.keywords is None: - self.keywords = keywords[:] # copy to make non-resizable - self.keywords_w = values_w[:] + self.keywords = keywords + self.keywords_w = values_w else: _check_not_duplicate_kwargs( self.space, self.keywords, keywords, values_w) diff --git a/pypy/objspace/std/dictmultiobject.py b/pypy/objspace/std/dictmultiobject.py --- a/pypy/objspace/std/dictmultiobject.py +++ b/pypy/objspace/std/dictmultiobject.py @@ -510,10 +510,13 @@ def view_as_kwargs(self, w_dict): d = self.unerase(w_dict.dstorage) - keys, values = [], [] + l = len(d) + keys, values = [None] * l, [None] * l + i = 0 for key, val in d.iteritems(): - keys.append(key) - values.append(val) + keys[i] = key + values[i] = val + i += 1 return keys, values class _WrappedIteratorMixin(object): diff --git a/pypy/objspace/std/kwargsdict.py b/pypy/objspace/std/kwargsdict.py --- a/pypy/objspace/std/kwargsdict.py +++ b/pypy/objspace/std/kwargsdict.py @@ -145,7 +145,8 @@ w_dict.dstorage = storage def view_as_kwargs(self, w_dict): - return self.unerase(w_dict.dstorage) + keys, values_w = self.unerase(w_dict.dstorage) + return keys[:], values_w[:] # copy to make non-resizable class KwargsDictIterator(IteratorImplementation): _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit