This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Incorrect error messages for invalid whitespaces in f-string subexpressions
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, serhiy.storchaka
Priority: normal Keywords:

Created on 2017-05-31 20:24 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 1888 merged serhiy.storchaka, 2017-05-31 20:36
PR 2013 merged serhiy.storchaka, 2017-06-08 20:47
PR 2232 merged eric.smith, 2017-06-16 01:41
Messages (7)
msg294869 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-05-31 20:24
Python parser supports only ' ', '\t', '\x0c' and '\r' as whitespaces. The parser of f-strings raises incorrect error messages for subexpressions consistent only from whitespaces, if they contain whitespaces out this set.

>>> eval("\xa0")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 1
     
    ^
SyntaxError: invalid character in identifier
>>> eval("f'''{\xa0}'''")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 1
SyntaxError: f-string: empty expression not allowed
msg294870 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-05-31 20:39
PR 1888 makes error messages for f-string subexpressions consistent with error messages for expressions out of f-strings, simplifies and speeds up the parsing code.
msg295244 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-06-06 07:47
Could you please look at the patch Eric?
msg295420 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2017-06-08 11:57
Sorry, I've been busy. I'll get to this soon, though.
msg295463 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-06-08 20:43
New changeset 2e9cd5825c5ccdbb6f65a57c0c7941078e003c14 by Serhiy Storchaka in branch 'master':
bpo-30529: Fix errors for invalid whitespaces in f-string subexpressions. (#1888)
https://github.com/python/cpython/commit/2e9cd5825c5ccdbb6f65a57c0c7941078e003c14
msg295468 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-06-08 21:38
New changeset 570b1c971c31cd08dbf060f4e21636c40aa47786 by Serhiy Storchaka in branch '3.6':
[3.6] bpo-30529: Fix errors for invalid whitespaces in f-string subexpressions. (GH-1888) (#2013)
https://github.com/python/cpython/commit/570b1c971c31cd08dbf060f4e21636c40aa47786
msg295469 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-06-08 21:39
Thank you for your review Eric.
History
Date User Action Args
2022-04-11 14:58:47adminsetgithub: 74714
2017-06-16 01:41:02eric.smithsetpull_requests: + pull_request2277
2017-06-08 21:39:16serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg295469

stage: patch review -> resolved
2017-06-08 21:38:09serhiy.storchakasetmessages: + msg295468
2017-06-08 20:47:02serhiy.storchakasetpull_requests: + pull_request2078
2017-06-08 20:43:56serhiy.storchakasetmessages: + msg295463
2017-06-08 11:57:24eric.smithsetmessages: + msg295420
2017-06-06 07:47:08serhiy.storchakasetmessages: + msg295244
2017-05-31 20:39:16serhiy.storchakasetmessages: + msg294870
2017-05-31 20:36:28serhiy.storchakasetstage: patch review
2017-05-31 20:36:03serhiy.storchakasetpull_requests: + pull_request1966
2017-05-31 20:24:52serhiy.storchakacreate