bpo-42990: Add __builtins__ attribute to functions by vstinner · Pull Request #24559 · python/cpython

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

vstinner

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.

https://bugs.python.org/issue42990

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.

@vstinner

@markshannon: I wrote this PR to expose the new function attribute in Python but also to document the subtle behavior change.

Using the new attribute, cloudpickle will be able to hack the function builtins update the update method, as already done for function globals.

@markshannon

adorilson pushed a commit to adorilson/cpython that referenced this pull request

Mar 13, 2021
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.