mirror of
https://github.com/python/cpython.git
synced 2025-07-28 21:55:21 +00:00
#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:
parent
ca69bb90cb
commit
595f7a5bf9
3 changed files with 32 additions and 10 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue