Title: marshal reports EOFError for I/O errors when reading from a FILE* · Issue #155907 · python/cpython · GitHub
Open Graph Title: marshal reports EOFError for I/O errors when reading from a FILE* · Issue #155907 · python/cpython
X Title: marshal reports EOFError for I/O errors when reading from a FILE* · Issue #155907 · python/cpython
Description: Bug report The functions which read marshalled data from a FILE* never check ferror(), so a genuine I/O error is reported as if the file had simply ended. >>> import _testcapi, os >>> os.mkdir('d') >>> _testcapi.pymarshal_read_object_fro...
Open Graph Description: Bug report The functions which read marshalled data from a FILE* never check ferror(), so a genuine I/O error is reported as if the file had simply ended. >>> import _testcapi, os >>> os.mkdir('d')...
X Description: Bug report The functions which read marshalled data from a FILE* never check ferror(), so a genuine I/O error is reported as if the file had simply ended. >>> import _testcapi, os >>...
Opengraph URL: https://github.com/python/cpython/issues/155907
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"marshal reports EOFError for I/O errors when reading from a FILE*","articleBody":"# Bug report\n\nThe functions which read marshalled data from a `FILE*` never check `ferror()`, so a genuine I/O error is reported as if the file had simply ended.\n\n```pycon\n>>> import _testcapi, os\n>>> os.mkdir('d')\n>>> _testcapi.pymarshal_read_object_from_file('d')\nTraceback (most recent call last):\n ...\nEOFError: EOF read where object expected\n```\n\nThe real error is `EISDIR`. `PyMarshal_ReadLongFromFile()`, `PyMarshal_ReadShortFromFile()` and `PyMarshal_ReadLastObjectFromFile()` behave the same way.\n\nSignals are not checked either, so a read interrupted by Ctrl-C is reported as `EOFError` instead of raising `KeyboardInterrupt`.\n\n`Doc/c-api/marshal.rst` also documents only `EOFError`, `ValueError` and `TypeError` for these functions, which is inaccurate even today -- `MemoryError` is raised when the read buffer cannot be allocated.\n\nRelated: gh-101006 stopped `EOFError` from overriding an already set exception, but nothing sets `OSError` in the first place.\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-155909\n* gh-157417\n* gh-157452\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/serhiy-storchaka","@type":"Person","name":"serhiy-storchaka"},"datePublished":"2026-08-16T17:47:59Z","url":"https://github.com/python/cpython/issues/155907"}
| 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:53dea87c-fc42-0e4f-3442-ec8264e04ffa |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A646:17543D:3F45B7:504FD2:6B01FE35 |
| html-safe-nonce | aa420742d68bf5a4875b0be66294d69697a76b160046d0db0511a13b4399a070 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNjQ2OjE3NTQzRDozRjQ1Qjc6NTA0RkQyOjZCMDFGRTM1IiwidmlzaXRvcl9pZCI6IjM4NjI4MDExODE1OTYzMTkyODUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c39da33c712a767974fe92b078a9fd7e6e9274ea652c8581f26e2506d15f2cbc |
| hovercard-subject-tag | issue:5165569642 |
| 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/155907/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f4ca65ecf9c3404c32750fd482a2f8dbc79cc33456713d818e9271b50b6469e0/python/cpython/issues/155907 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f4ca65ecf9c3404c32750fd482a2f8dbc79cc33456713d818e9271b50b6469e0/python/cpython/issues/155907 |
| og:image:alt | Bug report The functions which read marshalled data from a FILE* never check ferror(), so a genuine I/O error is reported as if the file had simply ended. >>> import _testcapi, os >>> os.mkdir('d')... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | serhiy-storchaka |
| 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