Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

(3.12+) tokenize exception type is wrong #105390

Closed
Assignees
pablogsal
Labels
3.12only security fixes3.13bugs and security fixestype-bugAn unexpected behavior, bug, or error
@asottile

Description

@asottile

Bug report

the document exception type for thetokenize.* functions isTokenError -- however it appears it now raisesSyntaxError:https://docs.python.org/3.12/library/tokenize.html#tokenize.TokenError

Raised when either a docstring or expression that may be split over several lines is not completed anywhere in the file, for example:

importioimporttokenizelist(tokenize.generate_tokens(io.StringIO('"""').readline))
$python3.11 t.pyTraceback (most recent call last):  File "/home/asottile/workspace/switch-microcontroller/t.py", line 4, in <module>    list(tokenize.generate_tokens(io.StringIO('"""').readline))  File "/usr/lib/python3.11/tokenize.py", line 465, in _tokenize    raise TokenError("EOF in multi-line string", strstart)tokenize.TokenError: ('EOF in multi-line string', (1, 0))

and

#python3.13 t.pyTraceback (most recent call last):  File "/y/pyupgrade/t.py", line 4, in <module>    list(tokenize.generate_tokens(io.StringIO('"""').readline))  File "/usr/lib/python3.13/tokenize.py", line 526, in _generate_tokens_from_c_tokenizer    for info in it:  File "<string>", line 1    """    ^SyntaxError: unterminated triple-quoted string literal (detected at line 1)

Your environment

  • CPython versions tested on:c7bf74b
  • Operating system and architecture: ubuntu 22.04 x86_64

Linked PRs

Metadata

Metadata

Assignees

Labels

3.12only security fixes3.13bugs and security fixestype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp