Message387341
In Python 3.9 the binding is more late-ish binding, than true late binding.
Because globals['__builtins__'] is cached for each function activation, executing functions don't see updates.
Example:
>>> def f():
... print(len("test"))
... bltns = f.__globals__["__builtins__"]
... if hasattr(bltns, "__dict__"):
... bltns = bltns.__dict__
... new = bltns.copy()
... new["len"] = lambda x : 7
... f.__globals__["__builtins__"] = new
... print(len("test"))
...
>>>
>>> f()
4
4
>>> f()
7
7
True late binding would print:
>>> f()
4
7
>>> f()
7
7 |
|
Date |
User |
Action |
Args |
2021-02-19 18:44:36 | Mark.Shannon | set | recipients:
+ Mark.Shannon, gvanrossum, brett.cannon, rhettinger, vstinner, petr.viktorin, serhiy.storchaka, yselivanov |
2021-02-19 18:44:36 | Mark.Shannon | set | messageid: <1613760276.91.0.240584092046.issue42990@roundup.psfhosted.org> |
2021-02-19 18:44:36 | Mark.Shannon | link | issue42990 messages |
2021-02-19 18:44:36 | Mark.Shannon | create | |
|