Title: pickle: respect dispatch for functions again
Type: enhancement Stage: needs patch
Components: Extension Modules Versions: Python 3.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: alexandre.vassalotti, hniksic, pitrou, serhiy.storchaka, torkve
Priority: normal Keywords: patch

Created on 2016-05-05 00:13 by torkve, last changed 2018-01-08 12:52 by serhiy.storchaka.

File name Uploaded Description Edit
function_pickle.patch torkve, 2016-05-05 00:13 Patch for custom function picklers support review
function_pickle.patch torkve, 2016-05-06 10:21 Patch for custom function picklers support. v2 review
Messages (5)
msg264866 - (view) Author: Vsevolod Velichko (torkve) * Date: 2016-05-05 00:13
The commit [2] removed support for handling unpicklable functions with copyreg override from cpickle due to lack of the same feature in pickle.
This patch restores that feature and adds the support of it to pickle.

[1] Original discussion:
msg264950 - (view) Author: Hrvoje Nikšić (hniksic) * Date: 2016-05-06 09:22
You can simplify pickle_lambda in the test by using marshal.dumps(code_obj) and marshal.loads(code_obj) to dump and load the code object without going through its entire guts. It would be a shame to have to change a pickle test just because some detail of the code object implementation changes.
msg264958 - (view) Author: Vsevolod Velichko (torkve) * Date: 2016-05-06 10:21
I was trying to avoid additional imports in the test.
But your point of view seems more reasonable, so I reupload the fixed patch.
msg279809 - (view) Author: Vsevolod Velichko (torkve) * Date: 2016-10-31 17:15
Hi, any progress here?
msg288153 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-02-19 18:58
Is saving global an atomic operation? Falling back to using reduce can be not safe if some data was written during saving global. That also might make error messages less helpful. Is not founding a function the only cause of PicklingError? Raising and catching an exception is not very efficient. Shouldn't the fallback be used for classes and C functions?

If add this feature the patch should be significantly reworked.
Date User Action Args
2018-01-08 12:52:28serhiy.storchakasetassignee: serhiy.storchaka
2017-02-19 18:58:51serhiy.storchakasetversions: + Python 3.7, - Python 3.6
nosy: + serhiy.storchaka

messages: + msg288153

type: behavior -> enhancement
stage: patch review -> needs patch
2016-10-31 17:15:16torkvesetmessages: + msg279809
2016-05-06 10:21:04torkvesetfiles: + function_pickle.patch

messages: + msg264958
2016-05-06 09:22:40hniksicsetnosy: + hniksic
messages: + msg264950
2016-05-06 07:14:41SilentGhostsetnosy: + pitrou, alexandre.vassalotti

stage: patch review
2016-05-05 00:13:46torkvecreate