classification
Title: Highlight invalid ranges in SyntaxErrors
Type: Stage: resolved
Components: Parser Versions: Python 3.11, Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: aroberge, eric.araujo, lukasz.langa, lys.nikolaou, miss-islington, pablogsal, terry.reedy
Priority: normal Keywords: patch

Created on 2021-04-22 18:08 by pablogsal, last changed 2021-10-04 19:18 by pablogsal. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 25525 merged pablogsal, 2021-04-22 18:08
PR 25582 closed terry.reedy, 2021-04-24 22:35
PR 28558 merged terry.reedy, 2021-09-25 03:12
PR 28562 merged lukasz.langa, 2021-09-25 09:05
PR 28576 merged pablogsal, 2021-09-27 00:12
PR 28582 merged miss-islington, 2021-09-27 13:37
Messages (10)
msg391620 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-04-22 18:08
To improve the user experience understanding what part of the error messages associated to SyntaxErrors are wrong, we can highlight the whole error range and not only place the caret at the first character. In this way:

>>> foo(x, z for z in range(10), t, w)
  File "<stdin>", line 1
    foo(x, z for z in range(10), t, w)
           ^
SyntaxError: Generator expression must be parenthesized

becomes

>>> foo(x, z for z in range(10), t, w)
  File "<stdin>", line 1
    foo(x, z for z in range(10), t, w)
           ^^^^^^^^^^^^^^^^^^^^
SyntaxError: Generator expression must be parenthesized
msg391697 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-04-23 13:27
New changeset a77aac4fca9723b8fd52a832f3e9df13beb25113 by Pablo Galindo in branch 'master':
bpo-43914: Highlight invalid ranges in SyntaxErrors (#25525)
https://github.com/python/cpython/commit/a77aac4fca9723b8fd52a832f3e9df13beb25113
msg391729 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2021-04-23 19:32
What a great, useful change!
msg391808 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-04-24 21:46
Great!!!  I also tried
>>> try: compile("a xyzjdkjfk", '', 'single')
except SyntaxError as e:
	print(e, e.msg, e.lineno, e.offset, e.end_lineno, e.end_offset)

	
invalid syntax. Perhaps you forgot a comma? (, line 1) invalid syntax. Perhaps you forgot a comma? 1 1 1 12

The language change that enables the display change is the addition of end_lineno and end_offset attributes.  I will look into using these in IDLE.  I will submit a PR to augment the What's New entry, so others can  also improve their error marking.
msg402611 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-25 09:04
New changeset 71f8ff45c62bd6b792919ac7c3804a8628ae12cb by Terry Jan Reedy in branch 'main':
bpo-43914: Whats New 310: add new SyntaxError attributes (GH-28558)
https://github.com/python/cpython/commit/71f8ff45c62bd6b792919ac7c3804a8628ae12cb
msg402615 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-25 09:32
New changeset c523022ba8f81a3661b4ac8be81706ed095d5769 by Łukasz Langa in branch '3.10':
[3.10] bpo-43914: What's New 3.10: add new SyntaxError attributes (GH-28558) (GH-28562)
https://github.com/python/cpython/commit/c523022ba8f81a3661b4ac8be81706ed095d5769
msg402616 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-25 09:33
This is complete now. Thanks! ✨ 🍰 ✨
msg402711 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-09-27 13:37
New changeset e5f13ce5b48b551c09fdd0faeafa6ecf860de51c by Pablo Galindo Salgado in branch 'main':
bpo-43914: Correctly highlight SyntaxError exceptions for invalid generator expression in function calls (GH-28576)
https://github.com/python/cpython/commit/e5f13ce5b48b551c09fdd0faeafa6ecf860de51c
msg402713 - (view) Author: miss-islington (miss-islington) Date: 2021-09-27 14:05
New changeset 9e209d48cac35108f3955d3f610b6ce60b574ecc by Miss Islington (bot) in branch '3.10':
bpo-43914: Correctly highlight SyntaxError exceptions for invalid generator expression in function calls (GH-28576)
https://github.com/python/cpython/commit/9e209d48cac35108f3955d3f610b6ce60b574ecc
msg403163 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-10-04 19:18
New changeset 0eb57c3be47e45b10124428ab45827467cd2d58e by Pablo Galindo (Łukasz Langa) in branch '3.10':
[3.10] bpo-43914: What's New 3.10: add new SyntaxError attributes (GH-28558) (GH-28562)
https://github.com/python/cpython/commit/0eb57c3be47e45b10124428ab45827467cd2d58e

New changeset 3397e3192ccc95ff7076f735930d2f4c60fbc278 by Pablo Galindo (Miss Islington (bot)) in branch '3.10':
bpo-43914: Correctly highlight SyntaxError exceptions for invalid generator expression in function calls (GH-28576)
https://github.com/python/cpython/commit/3397e3192ccc95ff7076f735930d2f4c60fbc278
History
Date User Action Args
2021-10-04 19:18:42pablogsalsetmessages: + msg403163
2021-09-27 14:05:28miss-islingtonsetmessages: + msg402713
2021-09-27 13:37:56miss-islingtonsetnosy: + miss-islington

pull_requests: + pull_request26964
2021-09-27 13:37:51pablogsalsetmessages: + msg402711
2021-09-27 00:12:51pablogsalsetpull_requests: + pull_request26959
2021-09-25 09:33:00lukasz.langasetstatus: open -> closed
versions: + Python 3.11
messages: + msg402616

resolution: fixed
stage: patch review -> resolved
2021-09-25 09:32:33lukasz.langasetmessages: + msg402615
2021-09-25 09:05:28lukasz.langasetpull_requests: + pull_request26945
2021-09-25 09:04:16lukasz.langasetnosy: + lukasz.langa
messages: + msg402611
2021-09-25 03:12:53terry.reedysetpull_requests: + pull_request26941
2021-04-25 11:06:50arobergesetnosy: + aroberge
2021-04-24 22:35:49terry.reedysetstage: patch review
pull_requests: + pull_request24302
2021-04-24 21:46:00terry.reedysetnosy: + terry.reedy
messages: + msg391808
2021-04-23 19:32:02eric.araujosetnosy: + eric.araujo
messages: + msg391729
2021-04-23 13:27:25pablogsalsetmessages: + msg391697
2021-04-22 18:13:31pablogsalsetcomponents: + Parser
2021-04-22 18:10:30pablogsalsetnosy: + lys.nikolaou

stage: patch review -> (no value)
2021-04-22 18:08:24pablogsalsetkeywords: + patch
stage: patch review
pull_requests: + pull_request24245
2021-04-22 18:08:13pablogsalsetversions: + Python 3.10
2021-04-22 18:08:10pablogsalcreate