Title: Inconsistency in handling None handlers in the Python and C implementations of pickle · Issue #93627 · python/cpython · GitHub
Open Graph Title: Inconsistency in handling None handlers in the Python and C implementations of pickle · Issue #93627 · python/cpython
X Title: Inconsistency in handling None handlers in the Python and C implementations of pickle · Issue #93627 · python/cpython
Description: In the Python implementation of pickle setting some handlers to None causes a fallback to other methods. Setting Pickler.reducer_override to None has the same effect as not setting this attribute -- falling back to other methods. Setting...
Open Graph Description: In the Python implementation of pickle setting some handlers to None causes a fallback to other methods. Setting Pickler.reducer_override to None has the same effect as not setting this attribute -...
X Description: In the Python implementation of pickle setting some handlers to None causes a fallback to other methods. Setting Pickler.reducer_override to None has the same effect as not setting this attribute -...
Opengraph URL: https://github.com/python/cpython/issues/93627
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Inconsistency in handling None handlers in the Python and C implementations of pickle","articleBody":"In the Python implementation of `pickle` setting some handlers to None causes a fallback to other methods.\r\n* Setting `Pickler.reducer_override` to None has the same effect as not setting this attribute -- falling back to other methods.\r\n* Setting the `dispatch_table` to None leads to falling back to `__reduce_ex__`.\r\n* Setting the `__reduce_ex__` attribute to None leads to falling back to `__reduce__`.\r\n* Setting the `__setstate__` attribute to None leads to falling back to the default implementation of `__setstate__` (setting `__dict__` and slots).\r\n\r\nIn the C implementation all this leads to `TypeError: 'NoneType' object is not callable`.\r\n\r\nThe `copy` module follows the Python implementation of `pickle`, except that it fails for any false value of `__reduce__`, not just None.\r\n\r\nIn most other code setting a dunder method to None leads to a TypeError (either raise explicitly or just generic \"'NoneType' object is not callable\").\r\n\r\nWe should decide what behavior should be in the `pickle` and `copy` module. On one hand, the Python implementation was primary. On other hand, it was inconsistent between the `pickle` and `copy` modules and was already changed in the past, the C implementation of `pickle` is now used by most users, and it is more consistent with other code.\r\n\r\nSee also:\r\nhttps://mail.python.org/archives/list/python-dev@python.org/thread/YGAK34DRWJFSIV2VZ4NC2J24XO37GCMM/\r\nhttps://docs.python.org/3.10/reference/datamodel.html#id2\r\nhttps://github.com/python/cpython/issues/70146\r\nhttps://github.com/python/cpython/issues/55781\r\nhttps://github.com/python/cpython/issues/60755\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-103035\n* gh-109498\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/serhiy-storchaka","@type":"Person","name":"serhiy-storchaka"},"datePublished":"2022-06-09T04:29:12.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/93627/cpython/issues/93627"}
| 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:defd4025-cc59-4f4d-3a2e-1e837be45352 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B9E4:29957D:26539E1:3410037:696ADCBA |
| html-safe-nonce | 9a94005c1e04576e052798aff43a10d2848acd9c3bb4620d705f579fe8275010 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOUU0OjI5OTU3RDoyNjUzOUUxOjM0MTAwMzc6Njk2QURDQkEiLCJ2aXNpdG9yX2lkIjoiNjM0ODAzMDk0NzM3NDA2Mjc3OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0b850f547d945d93ddce1705bc537bc067597861674d918c34ca96da9390ba70 |
| hovercard-subject-tag | issue:1265576430 |
| 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/93627/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5310576477bf8cc55f81d0fed117321ddd05d37caac96db077e0601c564567cb/python/cpython/issues/93627 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5310576477bf8cc55f81d0fed117321ddd05d37caac96db077e0601c564567cb/python/cpython/issues/93627 |
| og:image:alt | In the Python implementation of pickle setting some handlers to None causes a fallback to other methods. Setting Pickler.reducer_override to None has the same effect as not setting this attribute -... |
| 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 | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| 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 | 524a93f2c1f36522a3b4be4c110467ee4172245d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width