Skip to content

Commit

Permalink
gh-105390: Correctly raise TokenError instead of SyntaxError for toke…
Browse files Browse the repository at this point in the history
…nize errors
  • Loading branch information
pablogsal committed Jun 6, 2023
1 parent 0cb6b9b commit 98d4d62
Show file tree
Hide file tree
Showing 7 changed files with 1,934 additions and 24 deletions.
5 changes: 0 additions & 5 deletions Doc/library/tokenize.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,6 @@ function it uses to do this is available:
2,
3

Note that unclosed single-quoted strings do not cause an error to be
raised. They are tokenized as :data:`~token.ERRORTOKEN`, followed by the
tokenization of their contents.


.. _tokenize-cli:

Command-Line Usage
Expand Down
11 changes: 6 additions & 5 deletions Doc/whatsnew/3.12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1490,14 +1490,15 @@ Changes in the Python API
Additionally, there may be some minor behavioral changes as a consecuence of the
changes required to support :pep:`701`. Some of these changes include:

* Some final ``DEDENT`` tokens are now emitted within the bounds of the
input. This means that for a file containing 3 lines, the old version of the
tokenizer returned a ``DEDENT`` token in line 4 whilst the new version returns
the token in line 3.

* The ``type`` attribute of the tokens emitted when tokenizing some invalid Python
characters such as ``!`` has changed from ``ERRORTOKEN`` to ``OP``.

* Incomplete single-line strings now also raise :exc:`TokenError` as incomplete
multiline strings do.

* Some incomplete or invalid Python code now raises :exc:`TokenError` instead of
returning arbitrary ``ERRORTOKEN`` tokens when tokenizing it.

Build Changes
=============

Expand Down
Loading

0 comments on commit 98d4d62

Please sign in to comment.