Skip to content

Commit

Permalink
bpo-44409: Fix error location in tokenizer errors that happen during …
Browse files Browse the repository at this point in the history
…initialization (GH-26712)
  • Loading branch information
pablogsal committed Jun 14, 2021
1 parent cc8ecf6 commit 507ed6f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions Lib/test/test_exceptions.py
Expand Up @@ -246,6 +246,7 @@ def baz():
check("pass\npass\npass\n(1+)\npass\npass\npass", 4, 4)
check("(1+)", 1, 4)
check("[interesting\nfoo()\n", 1, 1)
check(b"\xef\xbb\xbf#coding: utf8\nprint('\xe6\x88\x91')\n", 0, -1)

# Errors thrown by symtable.c
check('x = [(yield i) for i in range(3)]', 1, 5)
Expand Down
@@ -0,0 +1,2 @@
Fix error location information for tokenizer errors raised on initialization
of the tokenizer. Patch by Pablo Galindo.
1 change: 1 addition & 0 deletions Parser/pegen.c
Expand Up @@ -283,6 +283,7 @@ static void
raise_tokenizer_init_error(PyObject *filename)
{
if (!(PyErr_ExceptionMatches(PyExc_LookupError)
|| PyErr_ExceptionMatches(PyExc_SyntaxError)
|| PyErr_ExceptionMatches(PyExc_ValueError)
|| PyErr_ExceptionMatches(PyExc_UnicodeDecodeError))) {
return;
Expand Down

0 comments on commit 507ed6f

Please sign in to comment.