in dict displays, evaluate the key before the value (closes #11205)

Patch partially by Steve Dougherty.
This commit is contained in:
Benjamin Peterson 2015-05-28 14:30:26 -05:00
parent 44e625860b
commit ee85339cc6
6 changed files with 127 additions and 113 deletions

View file

@ -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"""