syntax error message in f-string doesn't report line number

Bug #1872209 reported by Simon Lambourn
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python3-defaults (Ubuntu)
New
Undecided
Unassigned

Bug Description

I accidentally came across this annoying 'feature' or more likely, bug.

The following code
   f"...foo ... {**kwargs} ..."
produces a very basic syntax error message with no line number in the source file:

  File "<fstring>", line 1
    (**kwargs)
      ^
SyntaxError: invalid syntax

This is the error message I would expect from the interpreter, but not when running a python script. A demo script is as follows:

    ''' f-string bug demonstration '''

    def main(*args, **kwargs):
        print(f"main() called with *args={*args}, **kwargs={**kwargs}")

With a longer python file, it is hard to find the offending line. Should the line number be displayed in the error message?

ProblemType: Bug
DistroRelease: Ubuntu 19.10
Package: python3 3.7.5-1
ProcVersionSignature: Ubuntu 5.3.0-46.38-generic 5.3.18
Uname: Linux 5.3.0-46-generic x86_64
ApportVersion: 2.20.11-0ubuntu8.8
Architecture: amd64
CurrentDesktop: ubuntu:GNOME
Date: Sat Apr 11 17:08:35 2020
SourcePackage: python3-defaults
UpgradeStatus: Upgraded to eoan on 2019-10-23 (170 days ago)

Revision history for this message
Simon Lambourn (simon-lambourn-o) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.