[issue43228] Regression in function builtins

STINNER Victor report at bugs.python.org
Wed Feb 17 12:46:14 EST 2021


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

Attached func_builtins2.py mimicks the cloudpicke bug:
---
def func(s): return len(s)

code = func.__code__
FuncType = type(func)

func2_globals = {}
func2 = FuncType(code, func2_globals)
# func2.func_builtins = {'None': None}
func2.__globals__['__builtins__'] = __builtins__

# frame created with {'None': None} builtins: "len" key is missing
func2("abc")
---

In Python 3.10, setting func2.__globals__['__builtins__'] has no longer an impact on the frame created to call func2().

----------
Added file: https://bugs.python.org/file49816/func_builtins2.py

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


More information about the Python-bugs-list mailing list