classification
Title: problem with traceback for syntax error in f-string
Type: behavior Stage: needs patch
Components: Interpreter Core Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: eric.smith Nosy List: bgailer, eric.smith, josh.r, serhiy.storchaka
Priority: normal Keywords:

Created on 2018-08-08 20:42 by bgailer, last changed 2018-09-24 16:53 by eric.smith.

Messages (6)
msg323301 - (view) Author: bob gailer (bgailer) Date: 2018-08-08 20:42
Inconsistent tracebacks. Note that the traceback for bug.py does not 
reference the
module file and line number.

# bug.py
def f():
   f'''
   {d e}'''
a=b

import bug

Traceback (most recent call last):
   File "<fstring>", line 1
     (d e)
        ^
SyntaxError: invalid syntax

----------------------------------------

# bug2.py
def f():
   f'''
   {de}'''
a=b

import bug2
bug2.f()

Traceback (most recent call last):
   File "C:\python\bug2.py", line 5, in <module>
     a=b
NameError: name 'b' is not defined
msg323309 - (view) Author: Josh Rosenberg (josh.r) * Date: 2018-08-09 01:25
So the bug is that the line number and module are incorrect for the f-string, right? Nothing else?
msg323311 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2018-08-09 02:39
I think this is a duplicate, but I can't find the exact issue. I don't think it's exactly the same as #29051.
msg326264 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2018-09-24 16:35
I worked on this at the core sprint, and I have a patch almost ready.
msg326268 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-09-24 16:48
Great! I was going to take it. Will be glad to make a review.
msg326269 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2018-09-24 16:53
It's more elaborate than I'd like, but I think it's the right way to solve it: I'm passing in the starting line and column number to the parser machinery.
History
Date User Action Args
2018-09-24 16:53:45eric.smithsetmessages: + msg326269
2018-09-24 16:48:48serhiy.storchakasetmessages: + msg326268
2018-09-24 16:35:09eric.smithsetmessages: + msg326264
2018-09-24 16:33:21serhiy.storchakasetnosy: + serhiy.storchaka
2018-08-09 02:39:06eric.smithsetassignee: eric.smith
type: behavior
components: + Interpreter Core
versions: + Python 3.6, Python 3.7, Python 3.8
nosy: + eric.smith

messages: + msg323311
stage: needs patch
2018-08-09 01:25:28josh.rsetnosy: + josh.r
messages: + msg323309
2018-08-08 20:42:15bgailercreate