Funny behavior of IDLE 3.7.0

Chris Angelico rosuav at gmail.com
Tue Nov 12 19:14:27 EST 2019


On Wed, Nov 13, 2019 at 11:00 AM Terry Reedy <tjreedy at udel.edu> wrote:
>
> On 11/12/2019 12:00 PM, Chris Angelico wrote:
> > On Wed, Nov 13, 2019 at 3:57 AM Terry Reedy <tjreedy at udel.edu> wrote:
> >>
> >> On 11/12/2019 8:29 AM, Chris Angelico wrote:
> >>
> >>> The OP said that the equals sign in the *first* line was flagged as
> >>> invalid syntax. Implication being that the error is being reported on
> >>> the line "i = 4", not on the print at the end. And in fact, I can
> >>> confirm this. Run | Check Module reports an error where i is assigned
> >>> to. Here's how it looks in command-line Python:
> >>>
> >>> $ python3.7 demo.py
> >>>     File "<fstring>", line 1
> >>>       (i=)
> >>>         ^
> >>> SyntaxError: invalid syntax
> >>>
> >>> Newer Pythons are happy with this example, but if you replace the
> >>> error with something else - say, f'{i+}' - then the same phenomenon
> >>> occurs. Command-line Python reports the error on line 1 of
> >>> "<fstring>", and Idle misinterprets that as line 1 of the original
> >>> file.
> >>>
> >>> This looks like an error reporting flaw in f-string handling.
> >>
> >> Can you open a bug issue (if not one already) and nosy me?
> >> This is awful for any IDE that processes error messages.
> >>
> >> Replacing {} with () is a secondary bug.  The actual code
> >>     {i=}
> >> would be clearer, and make it easier for an IDE to search for the real line.
> >>
> >
> > I can do that, but I actually think the correct fix isn't inside Idle.
>
> Right.  I meant a bug report against core Python.
>
> If the real bug is not fixed, I might do a workaround for IDLE, but I
> would prefer not.
>

Gotcha!

Turns out there is actually an open bug:

https://bugs.python.org/issue34364

But it cites a GitHub PR that has been merged already:

https://github.com/python/cpython/pull/10021

So I'm not sure what status actually is, since the current master
branch still has the problem.

ChrisA


More information about the Python-list mailing list