#2016 Fix a crash in function call when the **kwargs dictionary is mutated

during the function call setup.

This even gives a slight speedup, probably because tuple allocation
is faster than PyMem_NEW.
This commit is contained in:
Amaury Forgeot d'Arc 2009-06-25 22:29:29 +00:00
parent ca69bb90cb
commit 595f7a5bf9
3 changed files with 32 additions and 10 deletions

View file

@ -251,6 +251,24 @@ TypeError if te dictionary is not empty
...
TypeError: id() takes no keyword arguments
A corner case of keyword dictionary items being deleted during
the function call setup. See <http://bugs.python.org/issue2016>.
>>> class Name(str):
... def __eq__(self, other):
... try:
... del x[self]
... except KeyError:
... pass
... return str.__eq__(self, other)
... def __hash__(self):
... return str.__hash__(self)
>>> x = {Name("a"):1, Name("b"):2}
>>> def f(a, b):
... print a,b
>>> f(**x)
1 2
"""
import unittest