bpo-42990: Add __builtins__ attribute to functions (GH-24559)
Expose the new PyFunctionObject.func_builtins member in Python as a
new __builtins__ attribute on functions.
Document also the behavior change in What's New in Python 3.10.
diff --git a/Lib/test/test_funcattrs.py b/Lib/test/test_funcattrs.py
index 11d68cc..15cf250 100644
--- a/Lib/test/test_funcattrs.py
+++ b/Lib/test/test_funcattrs.py
@@ -73,6 +73,11 @@ def test___globals__(self):
self.cannot_set_attr(self.b, '__globals__', 2,
(AttributeError, TypeError))
+ def test___builtins__(self):
+ self.assertIs(self.b.__builtins__, __builtins__)
+ self.cannot_set_attr(self.b, '__builtins__', 2,
+ (AttributeError, TypeError))
+
def test___closure__(self):
a = 12
def f(): print(a)