Funny behavior of IDLE 3.7.0

Terry Reedy tjreedy at udel.edu
Tue Nov 12 18:58:58 EST 2019


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.

> See the followup regarding the difference between SyntaxError and
> NameError; in the latter case, the error is more usefully reported.
> 
> ChrisA
> 


-- 
Terry Jan Reedy



More information about the Python-list mailing list