Title: mailbox additional empty line after from with unix/windows line encoding · Issue #110501 · python/cpython · GitHub
Open Graph Title: mailbox additional empty line after from with unix/windows line encoding · Issue #110501 · python/cpython
X Title: mailbox additional empty line after from with unix/windows line encoding · Issue #110501 · python/cpython
Description: Bug report Bug description: Hi all :) I transferred Thunderbird files from a Linux machine to a Windows machine. So the line endings remain in Linux type. When I read such an mbox with python, it breaks. After writing the message to a ne...
Open Graph Description: Bug report Bug description: Hi all :) I transferred Thunderbird files from a Linux machine to a Windows machine. So the line endings remain in Linux type. When I read such an mbox with python, it b...
X Description: Bug report Bug description: Hi all :) I transferred Thunderbird files from a Linux machine to a Windows machine. So the line endings remain in Linux type. When I read such an mbox with python, it b...
Opengraph URL: https://github.com/python/cpython/issues/110501
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mailbox additional empty line after from with unix/windows line encoding","articleBody":"# Bug report\n\n### Bug description:\n\nHi all :)\n\nI transferred Thunderbird files from a Linux machine to a Windows machine. So the line endings remain in Linux type.\n\nWhen I read such an mbox with python, it breaks. After writing the message to a new mbox file, a new line gets doubled. Here is what I get:\n\n```\nFrom - Sat Apr 6 20:13:31 2013\n\nFrom: \u003cboa@example.com>\nTo: \u003cjarekczek@example.com>\nDate: Thu, 4 Apr 2013 12:14:58 +0200\nSubject: simple\n\nhello\n```\n\nThe original file just didn't contain the extra empty line at the beginning.\n\nThe issue is gone if I translate the input file to Windows endings.\n\nI guess the source of the problem is located in `mailbox._mboxMMDF.get_message` where the line ending should be stripped from `from_line`, but it fails, because `linesep` is `\\r\\n`:\n\n`from_line = self._file.readline().replace(linesep, b'')`\n\nThunderbird for Windows deals well with transferred files. Even if I copy the message between folders, it preserves original line endings. That shows it is not tied to any specific line ending. I think we should do the same good thing.\n\nA quick fix would be just to remove any sequence of `\\r\\n` characters from the ending of `from_line`.\n\n### CPython versions tested on:\n\n3.10, 3.12\n\n### Operating systems tested on:\n\nWindows","author":{"url":"https://github.com/jarekczek","@type":"Person","name":"jarekczek"},"datePublished":"2023-10-07T11:22:31Z","url":"https://github.com/python/cpython/issues/110501"}
| 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:cd441242-2a00-bd3f-4197-244e5968c673 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C750:2E124E:389338A:4848658:6B020207 |
| html-safe-nonce | 5af109d37b69d3e580e189dd77cae2b3c3de2ef419b9871678d050556790f891 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNzUwOjJFMTI0RTozODkzMzhBOjQ4NDg2NTg6NkIwMjAyMDciLCJ2aXNpdG9yX2lkIjoiMzM4MjA2NjM4MTIxMzI3MDUzNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7c4fd7156e294f71c7bee6c06262634f7a6c7bcaea1ec554affb76250fad3a76 |
| hovercard-subject-tag | issue:1931312215 |
| 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/110501/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8f40874db6ad928e7df3509460256e8ee27073ad4f2c4fbdd3ce95e461caf4cc/python/cpython/issues/110501 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8f40874db6ad928e7df3509460256e8ee27073ad4f2c4fbdd3ce95e461caf4cc/python/cpython/issues/110501 |
| og:image:alt | Bug report Bug description: Hi all :) I transferred Thunderbird files from a Linux machine to a Windows machine. So the line endings remain in Linux type. When I read such an mbox with python, it b... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jarekczek |
| 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 | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width