summaryrefslogtreecommitdiff
path: root/Lib/test/test_extcall.py
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2009-06-25 22:29:29 +0000
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2009-06-25 22:29:29 +0000
commit595f7a5bf959f97b5d889ab5c7f86c06e36e8dfb (patch)
tree74ebe5456e7c8745184ed83e9899cf294c7ad3e8 /Lib/test/test_extcall.py
parentca69bb90cb6091453d74d9693653b1c649553782 (diff)
downloadcpython-git-595f7a5bf959f97b5d889ab5c7f86c06e36e8dfb.tar.gz
#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.
Diffstat (limited to 'Lib/test/test_extcall.py')
-rw-r--r--Lib/test/test_extcall.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_extcall.py b/Lib/test/test_extcall.py
index f4ab204279..a10887e163 100644
--- a/Lib/test/test_extcall.py
+++ b/Lib/test/test_extcall.py
@@ -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