mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
evaluate positional defaults before keyword-only defaults (closes #16967)
This commit is contained in:
parent
34a2a87d17
commit
1ef876cd28
7 changed files with 161 additions and 147 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue