Title: (3.12+) tokenize exception type is wrong · Issue #105390 · python/cpython · GitHub
Open Graph Title: (3.12+) tokenize exception type is wrong · Issue #105390 · python/cpython
X Title: (3.12+) tokenize exception type is wrong · Issue #105390 · python/cpython
Description: Bug report the document exception type for the tokenize.* functions is TokenError -- however it appears it now raises SyntaxError: https://docs.python.org/3.12/library/tokenize.html#tokenize.TokenError Raised when either a docstring or e...
Open Graph Description: Bug report the document exception type for the tokenize.* functions is TokenError -- however it appears it now raises SyntaxError: https://docs.python.org/3.12/library/tokenize.html#tokenize.TokenE...
X Description: Bug report the document exception type for the tokenize.* functions is TokenError -- however it appears it now raises SyntaxError: https://docs.python.org/3.12/library/tokenize.html#tokenize.TokenE...
Opengraph URL: https://github.com/python/cpython/issues/105390
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"(3.12+) tokenize exception type is wrong","articleBody":"\u003c!--\r\n If you're new to Python and you're not sure whether what you're experiencing is a bug, the CPython issue tracker is not\r\n the right place to seek help. Consider the following options instead:\r\n\r\n - reading the Python tutorial: https://docs.python.org/3/tutorial/\r\n - posting in the \"Users\" category on discuss.python.org: https://discuss.python.org/c/users/7\r\n - emailing the Python-list mailing list: https://mail.python.org/mailman/listinfo/python-list\r\n - searching our issue tracker (https://github.com/python/cpython/issues) to see if\r\n your problem has already been reported\r\n--\u003e\r\n\r\n# Bug report\r\n\r\nthe document exception type for the `tokenize.*` functions is `TokenError` -- however it appears it now raises `SyntaxError`: https://docs.python.org/3.12/library/tokenize.html#tokenize.TokenError\r\n\r\n\u003e Raised when either a docstring or expression that may be split over several lines is not completed anywhere in the file, for example:\r\n\r\n```python\r\nimport io\r\nimport tokenize\r\n\r\nlist(tokenize.generate_tokens(io.StringIO('\"\"\"').readline))\r\n```\r\n\r\n```console\r\n$ python3.11 t.py\r\nTraceback (most recent call last):\r\n File \"/home/asottile/workspace/switch-microcontroller/t.py\", line 4, in \u003cmodule\u003e\r\n list(tokenize.generate_tokens(io.StringIO('\"\"\"').readline))\r\n File \"/usr/lib/python3.11/tokenize.py\", line 465, in _tokenize\r\n raise TokenError(\"EOF in multi-line string\", strstart)\r\ntokenize.TokenError: ('EOF in multi-line string', (1, 0))\r\n```\r\nand\r\n\r\n```console\r\n# python3.13 t.py\r\nTraceback (most recent call last):\r\n File \"/y/pyupgrade/t.py\", line 4, in \u003cmodule\u003e\r\n list(tokenize.generate_tokens(io.StringIO('\"\"\"').readline))\r\n File \"/usr/lib/python3.13/tokenize.py\", line 526, in _generate_tokens_from_c_tokenizer\r\n for info in it:\r\n File \"\u003cstring\u003e\", line 1\r\n \"\"\"\r\n ^\r\nSyntaxError: unterminated triple-quoted string literal (detected at line 1)\r\n```\r\n\r\n# Your environment\r\n\r\n\u003c!-- Include as many relevant details as possible about the environment you experienced the bug in --\u003e\r\n\r\n- CPython versions tested on: c7bf74bacd\r\n- Operating system and architecture: ubuntu 22.04 x86_64\r\n\r\n\u003c!--\r\nYou can freely edit this text. Remove any lines you believe are unnecessary.\r\n--\u003e\r\n\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-105399\n* gh-105439\n* gh-105466\n* gh-105472\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/asottile","@type":"Person","name":"asottile"},"datePublished":"2023-06-06T14:44:19.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/105390/cpython/issues/105390"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8bfea3d0-629e-1c90-b99d-4f4b8679184c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E9F0:1E4FEF:5A958D:745A7E:696AE6A1 |
| html-safe-nonce | e43c147c524c90e3a9d0e6f593d42d46f0fe83f8df4449c0423095b724474661 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOUYwOjFFNEZFRjo1QTk1OEQ6NzQ1QTdFOjY5NkFFNkExIiwidmlzaXRvcl9pZCI6IjgzNjQ0ODU2NTI5NTgwNzg2MjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 4a0b6a6ebbc8ed05cee44e7b5480a04025d4df24aaa12fa8af156a32ce70a11c |
| hovercard-subject-tag | issue:1744024352 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/105390/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fa65854f8b2b8815db230c4a298e12e511d3e804b2245241cf46425ab7cac5ca/python/cpython/issues/105390 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fa65854f8b2b8815db230c4a298e12e511d3e804b2245241cf46425ab7cac5ca/python/cpython/issues/105390 |
| og:image:alt | Bug report the document exception type for the tokenize.* functions is TokenError -- however it appears it now raises SyntaxError: https://docs.python.org/3.12/library/tokenize.html#tokenize.TokenE... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | asottile |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3d84d50b3c75fa36755c3cf392edbc09e626f979 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width