Title: Pickle ignores custom getstate methods on TextIOWrapper in Python 3.12 · Issue #122559 · python/cpython · GitHub
Open Graph Title: Pickle ignores custom getstate methods on TextIOWrapper in Python 3.12 · Issue #122559 · python/cpython
X Title: Pickle ignores custom getstate methods on TextIOWrapper in Python 3.12 · Issue #122559 · python/cpython
Description: Bug report Bug description: So I am not entirely sure whether this is unintended behaviour, but it is definitely a noticeable change between 3.11 and 3.12 that is rather unintuitive import pickle from io import BytesIO, TextIOWrapper cla...
Open Graph Description: Bug report Bug description: So I am not entirely sure whether this is unintended behaviour, but it is definitely a noticeable change between 3.11 and 3.12 that is rather unintuitive import pickle f...
X Description: Bug report Bug description: So I am not entirely sure whether this is unintended behaviour, but it is definitely a noticeable change between 3.11 and 3.12 that is rather unintuitive import pickle f...
Opengraph URL: https://github.com/python/cpython/issues/122559
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Pickle ignores custom getstate methods on TextIOWrapper in Python 3.12","articleBody":"# Bug report\r\n\r\n### Bug description:\r\nSo I am not entirely sure whether this is unintended behaviour, but it is definitely a noticeable change between 3.11 and 3.12 that is rather unintuitive \r\n```python\r\nimport pickle\r\nfrom io import BytesIO, TextIOWrapper\r\n\r\nclass EncodedFile(TextIOWrapper):\r\n\tdef __getstate__(self):\r\n\t\treturn \"string\"\r\n\tdef __setstate__(self, state):\r\n\t\tpass\r\n\r\nfile = EncodedFile(BytesIO(b\"string\"))\r\npickle.dumps(file)\r\n```\r\nThis works in Python 3.11 and 3.10, but fails in 3.12 with \r\n```python\r\npickle.dumps(file)\r\nTypeError: cannot pickle 'EncodedFile' instances\r\n```\r\n\r\n\r\n### CPython versions tested on:\r\n\r\n3.10, 3.11, 3.12\r\n\r\n### Operating systems tested on:\r\n\r\nmacOS\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-122628\n* gh-133381\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/SimonSorgQC","@type":"Person","name":"SimonSorgQC"},"datePublished":"2024-08-01T12:26:59.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/122559/cpython/issues/122559"}
| 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:34a6c8ef-6eeb-755a-480e-0d65168de4d0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E4BC:DEDFE:2D8E16:3E0E8F:696AA50A |
| html-safe-nonce | 46244ff8180dca7013b87f3b8f6b2b7698668e4e81f55dbe08d39c089cd30dfe |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNEJDOkRFREZFOjJEOEUxNjozRTBFOEY6Njk2QUE1MEEiLCJ2aXNpdG9yX2lkIjoiMjcwNzQ3MTE5MjQ0NzE2NTcwNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 610771611abeb77e1249b8b787074d3930cd7f6bd3b071553adb559aca1794bf |
| hovercard-subject-tag | issue:2442324994 |
| 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/122559/issue_layout |
| twitter:image | https://opengraph.githubassets.com/94ccb3fdd6bca880f7e4c735ac2f9af8e646e8bcf848d310d454811a867568e4/python/cpython/issues/122559 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/94ccb3fdd6bca880f7e4c735ac2f9af8e646e8bcf848d310d454811a867568e4/python/cpython/issues/122559 |
| og:image:alt | Bug report Bug description: So I am not entirely sure whether this is unintended behaviour, but it is definitely a noticeable change between 3.11 and 3.12 that is rather unintuitive import pickle f... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | SimonSorgQC |
| hostname | github.com |
| expected-hostname | github.com |
| None | a51f97dbb9326f71c08ecb61577457d543c602124d1a2672871258ef37ac5261 |
| 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 | 4bd0eac606c70914085176ef312ebdcd97a8cdf1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width