mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
in dict displays, evaluate the key before the value (closes #11205)
Patch partially by Steve Dougherty.
This commit is contained in:
parent
44e625860b
commit
ee85339cc6
6 changed files with 127 additions and 113 deletions
|
@ -461,6 +461,17 @@ if 1:
|
|||
ast.body = [_ast.BoolOp()]
|
||||
self.assertRaises(TypeError, compile, ast, '<ast>', 'exec')
|
||||
|
||||
def test_dict_evaluation_order(self):
|
||||
i = 0
|
||||
|
||||
def f():
|
||||
nonlocal i
|
||||
i += 1
|
||||
return i
|
||||
|
||||
d = {f(): f(), f(): f()}
|
||||
self.assertEqual(d, {1: 2, 3: 4})
|
||||
|
||||
@support.cpython_only
|
||||
def test_same_filename_used(self):
|
||||
s = """def f(): pass\ndef g(): pass"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue