evaluate positional defaults before keyword-only defaults (closes #16967)

This commit is contained in:
Benjamin Peterson 2013-02-10 09:29:59 -05:00
parent 34a2a87d17
commit 1ef876cd28
7 changed files with 161 additions and 147 deletions

View file

@ -176,6 +176,14 @@ class KeywordOnlyArgTestCase(unittest.TestCase):
return __a
self.assertEqual(X().f(), 42)
def test_default_evaluation_order(self):
# See issue 16967
a = 42
with self.assertRaises(NameError) as err:
def f(v=a, x=b, *, y=c, z=d):
pass
self.assertEqual(str(err.exception), "global name 'b' is not defined")
def test_main():
run_unittest(KeywordOnlyArgTestCase)