New submission from Miguel Brito <miguel.mdebr...@gmail.com>:

Hi, I was playing around with Python's grammar and noticed that the error 
message for if expression is generic, so not very informative.

I decided to improve it slightly.

*From*:

```
>>> a = 42 if True
  File "<stdin>", line 1
    a = 42 if True
                  ^
SyntaxError: invalid syntax
```

*To*:

```
$ ./python
Python 3.10.0b4 (tags/v3.10.0b4-dirty:2ba4b20854, Jul 31 2021, 11:50:15) [GCC 
7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 42 if True
  File "<stdin>", line 1
    a = 42 if True
                  ^
SyntaxError: invalid syntax. Conditional expression expected an 'else' here.
```

----------
messages: 398633
nosy: miguendes
priority: normal
severity: normal
status: open
title: Improve syntax errors for invalid if expressions

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44792>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to