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, brett.cannon, gvanrossum, petr.viktorin, rhettinger, serhiy.storchaka, vstinner, yselivanov
Date 2021-02-19.18:44:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1613760276.91.0.240584092046.issue42990@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2021-02-19 18:44:36Mark.Shannonsetrecipients: + Mark.Shannon, gvanrossum, brett.cannon, rhettinger, vstinner, petr.viktorin, serhiy.storchaka, yselivanov
2021-02-19 18:44:36Mark.Shannonsetmessageid: <1613760276.91.0.240584092046.issue42990@roundup.psfhosted.org>
2021-02-19 18:44:36Mark.Shannonlinkissue42990 messages
2021-02-19 18:44:36Mark.Shannoncreate