[issue43228] Regression in function builtins

STINNER Victor report at bugs.python.org
Thu Feb 18 06:32:58 EST 2021


STINNER Victor <vstinner at python.org> added the comment:

> but __builtins__.__dict__ cannot be pickled.

I don't see why cloudpickle calls LambdaType() directly. It could use a helper in their cloudpickle.cloudpickle_fast which calls LambdaType() with the proper arguments, especially to get __builtins__. I don't think that cloudpickle should serialize __builtins__!

By the way, I'm not sure why the function constructor builds {'None': None} namespace for builtins rather than inheriting the current builtins namespace. IMO it's unconvenient.

If someone wants to override __builtins__, setting __builtins__ key in the globals namespace should be enough.

> Adding a "builtins" parameter to types.FunctionType() should be be enough.

Oh right, we should give the ability to control this important parameter!

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43228>
_______________________________________


More information about the Python-bugs-list mailing list