This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Mark.Shannon
Recipients Mark.Shannon, frenzy, pablogsal, vstinner
Date 2021-02-18.10:54:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1613645690.84.0.0638524557016.issue43228@roundup.psfhosted.org>
In-reply-to
Content
I don't think PR 24559 will be sufficient to fix this.

Pickled functions need to share the builtins dict, not just have a copy of it. Adding a "builtins" parameter to types.FunctionType() should be be enough.

So:

function(code, globals, name=None, argdefs=None, closure=None)
would become:
function(code, globals, name=None, argdefs=None, closure=None, builtins=None)

The change to cloudpickle is a bit complex as the pickle code would need to change the arguments to  types.FunctionType() from (code, globals, name, argdefs)
to
(code, globals, name, argdefs, None, __builtins__.__dict__)
but __builtins__.__dict__ cannot be pickled.

So cloudpickle will need to emit pickle bytecode to create the tuple, using the unpickler's __builtins__.__dict__.
History
Date User Action Args
2021-02-18 10:54:50Mark.Shannonsetrecipients: + Mark.Shannon, vstinner, frenzy, pablogsal
2021-02-18 10:54:50Mark.Shannonsetmessageid: <1613645690.84.0.0638524557016.issue43228@roundup.psfhosted.org>
2021-02-18 10:54:50Mark.Shannonlinkissue43228 messages
2021-02-18 10:54:50Mark.Shannoncreate