Skip to content

assert a := 1 produces unclear error message #138716

@sobolevn

Description

@sobolevn

Feature or enhancement

After 6bc65c3 is merged, there's one more case we can handle. See this todo:

>>> # TODO(@sobolevn): improve this message in the next PR
>>> assert a := 1
Traceback (most recent call last):
SyntaxError: invalid syntax

What happens? assert does not allow := without () in its body.
We need to improve the error message, because current state is not really clear for the user. Why there's a syntax error? How to fix it?

Refs #136616

Linked PRs

Metadata

Metadata

Assignees

Labels

3.15new features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)topic-parsertype-featureA feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions