Title: `UnboundLocalError` in `email._header_value_parser.parse_message_id` · Issue #134152 · python/cpython · GitHub
Open Graph Title: `UnboundLocalError` in `email._header_value_parser.parse_message_id` · Issue #134152 · python/cpython
X Title: `UnboundLocalError` in `email._header_value_parser.parse_message_id` · Issue #134152 · python/cpython
Description: During fuzzing of Python standard libraries, the following code snippet causes an UnboundLocalError with the following message: UnboundLocalError: cannot access local variable 'pos' where it is not associated with a value'. This occurs i...
Open Graph Description: During fuzzing of Python standard libraries, the following code snippet causes an UnboundLocalError with the following message: UnboundLocalError: cannot access local variable 'pos' where it is not...
X Description: During fuzzing of Python standard libraries, the following code snippet causes an UnboundLocalError with the following message: UnboundLocalError: cannot access local variable 'pos' where i...
Opengraph URL: https://github.com/python/cpython/issues/134152
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`UnboundLocalError` in `email._header_value_parser.parse_message_id`","articleBody":"During fuzzing of Python standard libraries, the following code snippet causes an `UnboundLocalError` with the following message: `UnboundLocalError: cannot access local variable 'pos' where it is not associated with a value'`. This occurs in the `_get_ptext_to_endchars` function at line 1035 in `email/_header_value_parser.py`.\n\n```python\nimport email._header_value_parser\nemail._header_value_parser.parse_message_id(\"\u003cT@[\")\n```\n\n### Exception Trace\n```pytb\nTraceback (most recent call last):\n File \"/usr/lib/python3.12/email/_header_value_parser.py\", line 2118, in get_msg_id\n token, value = get_dot_atom_text(value)\n ^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/lib/python3.12/email/_header_value_parser.py\", line 1344, in get_dot_atom_text\n raise errors.HeaderParseError(\"expected atom at a start of \"\nemail.errors.HeaderParseError: expected atom at a start of dot-atom-text but found '['\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File \"rep.py\", line 2, in \u003cmodule>\n email._header_value_parser.parse_message_id(\"\u003cT@[\")\n File \"/usr/lib/python3.12/email/_header_value_parser.py\", line 2149, in parse_message_id\n token, value = get_msg_id(value)\n ^^^^^^^^^^^^^^^^^\n File \"/usr/lib/python3.12/email/_header_value_parser.py\", line 2121, in get_msg_id\n token, value = get_no_fold_literal(value)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/lib/python3.12/email/_header_value_parser.py\", line 2066, in get_no_fold_literal\n token, value = get_dtext(value)\n ^^^^^^^^^^^^^^^^\n File \"/usr/lib/python3.12/email/_header_value_parser.py\", line 1557, in get_dtext\n ptext, value, had_qp = _get_ptext_to_endchars(value, '[]')\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/lib/python3.12/email/_header_value_parser.py\", line 1033, in _get_ptext_to_endchars\n pos = pos + 1\n ^^^\nUnboundLocalError: cannot access local variable 'pos' where it is not associated with a value\n```\n\n### CPython versions tested on:\n\n3.12, 3.11, 3.10, 3.9\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-134194\n* gh-134233\n* gh-134677\n* gh-134678\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/gabe-sherman","@type":"Person","name":"gabe-sherman"},"datePublished":"2025-05-17T19:20:21Z","url":"https://github.com/python/cpython/issues/134152"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:6b359423-5fdd-756e-e12e-ed02bc6e079c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AD8A:380435:96B413:BE0F05:6B021B2E |
| html-safe-nonce | f728797042ba01d75e13efc8bde4b60bd5bd65525bb3dfe1725b42cd42b4d95a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRDhBOjM4MDQzNTo5NkI0MTM6QkUwRjA1OjZCMDIxQjJFIiwidmlzaXRvcl9pZCI6IjM5MDY4NjI1OTM5NTU5OTQ0MTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9dd68ad448fb5c1b0c8703d08cc3b6f6d640f493ffeedf8e46c5d72c5eaadd54 |
| hovercard-subject-tag | issue:3071009872 |
| 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/134152/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fecf67e8a0d44d51f5702e248e8046447a0091a09ffd6a602b118dcfc3fefff2/python/cpython/issues/134152 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fecf67e8a0d44d51f5702e248e8046447a0091a09ffd6a602b118dcfc3fefff2/python/cpython/issues/134152 |
| og:image:alt | During fuzzing of Python standard libraries, the following code snippet causes an UnboundLocalError with the following message: UnboundLocalError: cannot access local variable 'pos' where it is not... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gabe-sherman |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width