bpo-40334: Error message for invalid default args in function call (GH-19973)

When parsing something like `f(g()=2)`, where the name of a default arg
is not a NAME, but an arbitrary expression, a specialised error message
is emitted.
This commit is contained in:
Lysandros Nikolaou 2020-05-07 13:44:06 +03:00 committed by GitHub
parent 2f37c355ab
commit 4638c64295
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 222 additions and 159 deletions

View file

@ -609,6 +609,9 @@ FAIL_SPECIALIZED_MESSAGE_CASES = [
("lambda *: pass", "named arguments must follow bare *"),
("lambda *,: pass", "named arguments must follow bare *"),
("lambda *, **a: pass", "named arguments must follow bare *"),
("f(g()=2", "expression cannot contain assignment, perhaps you meant \"==\"?"),
("f(a, b, *c, d.e=2", "expression cannot contain assignment, perhaps you meant \"==\"?"),
("f(*a, **b, c=0, d[1]=3)", "expression cannot contain assignment, perhaps you meant \"==\"?"),
]
GOOD_BUT_FAIL_TEST_CASES = [