mirror of
https://github.com/python/cpython.git
synced 2025-12-10 11:00:14 +00:00
Break a cycle created in the saboteur() function.
This commit is contained in:
parent
a44923fbfe
commit
5ff2ac2fa9
1 changed files with 5 additions and 2 deletions
|
|
@ -85,10 +85,13 @@ assert d == d2, "function call modified dictionary"
|
||||||
|
|
||||||
# what about willful misconduct?
|
# what about willful misconduct?
|
||||||
def saboteur(**kw):
|
def saboteur(**kw):
|
||||||
kw['x'] = locals()
|
kw['x'] = locals() # yields a cyclic kw
|
||||||
|
return kw
|
||||||
d = {}
|
d = {}
|
||||||
saboteur(a=1, **d)
|
kw = saboteur(a=1, **d)
|
||||||
assert d == {}
|
assert d == {}
|
||||||
|
# break the cycle
|
||||||
|
del kw['x']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
g(1, 2, 3, **{'x':4, 'y':5})
|
g(1, 2, 3, **{'x':4, 'y':5})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue