Title: Regression: ImportError for `HeaderWriteError` in long-running process post-Python update for CVE-2024-6923 · Issue #124170 · python/cpython · GitHub
Open Graph Title: Regression: ImportError for `HeaderWriteError` in long-running process post-Python update for CVE-2024-6923 · Issue #124170 · python/cpython
X Title: Regression: ImportError for `HeaderWriteError` in long-running process post-Python update for CVE-2024-6923 · Issue #124170 · python/cpython
Description: Bug report Bug description: Pull request #122233 introduced a new class HeaderWriteError in commit 0976339 and imports that from email.generator. This breaks running applications that have imported other parts of email before the update,...
Open Graph Description: Bug report Bug description: Pull request #122233 introduced a new class HeaderWriteError in commit 0976339 and imports that from email.generator. This breaks running applications that have imported...
X Description: Bug report Bug description: Pull request #122233 introduced a new class HeaderWriteError in commit 0976339 and imports that from email.generator. This breaks running applications that have imported...
Opengraph URL: https://github.com/python/cpython/issues/124170
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Regression: ImportError for `HeaderWriteError` in long-running process post-Python update for CVE-2024-6923","articleBody":"# Bug report\n\n### Bug description:\n\nPull request #122233 introduced a new class `HeaderWriteError` in commit 097633981879b3c9de9a1dd120d3aa585ecc2384 and imports that from `email.generator`.\n\nThis breaks running applications that have imported other parts of `email` before the update, and then try to import the generator past the update.\n\nNow this is a bit silly, but it is what `email.message.Message.as_string()` does, it imports `email.generator` *inside* the function - which may happen at any point of the program run-time rather than at startup.\n\nFor example, the following pseudo-code will fail, assuming it has not generated another email earlier or manually imported the `email.generator` module.\n\n```python\nimport email.message\n\u003cdo something for a long time, such as wait for a web form, Python is being upgraded here>\nmsg = \u003cprepare a message>\nmsg.as_string()\n```\n\nA particular instance of the issue is the `unattended-upgrades` package in Ubuntu and Debian, which will install the security update and then may send an email and fail there due to the ImportError, see https://bugs.launchpad.net/ubuntu/+source/python3.8/+bug/2080940.\n\nI'm wondering if it's feasible to add a workaround to the stable branches:\n\nCchange the email.generator module import:\n\n```python\nfrom email.errors import HeaderWriteError\n```\n\nto graciously support the previous version email.errors:\n\n```python\ntry:\n from email.errors import HeaderWriteError\nexcept ImportError:\n from email.errors import MessageError as HeaderWriteError\n```\n\nThis is a safe change, existing applications, where the import fails can't be having `except HeaderWriteError` statements anyway.\n\nThanks.\n\n### CPython versions tested on:\n\n3.12\n\n### Operating systems tested on:\n\n_No response_","author":{"url":"https://github.com/julian-klode","@type":"Person","name":"julian-klode"},"datePublished":"2024-09-17T12:02:59Z","url":"https://github.com/python/cpython/issues/124170"}
| 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:f7a8f70a-6093-9e52-c755-b70a7130b363 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E200:C93D7:2B5C2F:3CBEA2:6B005C64 |
| html-safe-nonce | 1d1301079423e98e17afa1c65f2945141f5fe6b76f0441cae74d5674eacc2b0a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjAwOkM5M0Q3OjJCNUMyRjozQ0JFQTI6NkIwMDVDNjQiLCJ2aXNpdG9yX2lkIjoiNDg1NzIwNTg5NzI1ODA5Nzc2NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0f5322b838a52570e6b4860554812e20ad449e29623d1bf6521aa344c011a308 |
| hovercard-subject-tag | issue:2530973376 |
| 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/124170/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1ee36c56aed7ff85d389964337a06e72685202c66060d37d5818ca89badb2f2d/python/cpython/issues/124170 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1ee36c56aed7ff85d389964337a06e72685202c66060d37d5818ca89badb2f2d/python/cpython/issues/124170 |
| og:image:alt | Bug report Bug description: Pull request #122233 introduced a new class HeaderWriteError in commit 0976339 and imports that from email.generator. This breaks running applications that have imported... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | julian-klode |
| hostname | github.com |
| expected-hostname | github.com |
| None | 29be975efff6507a5d135de9c7d634cf7ff8f0c55222a64386ab3202209aaf73 |
| 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 | eacd927ba6112e3b01ba99c762bd699a4a4f5df7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width