bpo-22057: Clarify eval() documentation by berkerpeksag · Pull Request #8812 · python/cpython (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation5 Commits1 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

berkerpeksag

If a globals dictionary without a 'builtins' key is passed to
eval(), a 'builtins' key will be inserted to the dictionary:

>>> eval("print('__builtins__' in globals())", {})
True

https://bugs.python.org/issue22057

@berkerpeksag

If a globals dictionary without a 'builtins' key is passed to eval(), a 'builtins' key will be inserted to the dictionary:

>>> eval("print('__builtins__' in globals())", {})
True

@vadmium

@miss-islington

Thanks @berkerpeksag for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request

Aug 19, 2018

@berkerpeksag @miss-islington

If a globals dictionary without a 'builtins' key is passed to eval(), a 'builtins' key will be inserted to the dictionary:

>>> eval("print('__builtins__' in globals())", {})
True

(As a result of this behavior, we can use the builtins print() and globals() even if we passed a dictionary without a 'builtins' key to eval().) (cherry picked from commit 225b055)

Co-authored-by: Berker Peksag berker.peksag@gmail.com

@bedevere-bot

@berkerpeksag

Thanks for the review, Martin.

@bedevere-bot

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request

Aug 19, 2018

@berkerpeksag @miss-islington

If a globals dictionary without a 'builtins' key is passed to eval(), a 'builtins' key will be inserted to the dictionary:

>>> eval("print('__builtins__' in globals())", {})
True

(As a result of this behavior, we can use the builtins print() and globals() even if we passed a dictionary without a 'builtins' key to eval().) (cherry picked from commit 225b055)

Co-authored-by: Berker Peksag berker.peksag@gmail.com

miss-islington added a commit that referenced this pull request

Aug 19, 2018

@miss-islington @berkerpeksag

If a globals dictionary without a 'builtins' key is passed to eval(), a 'builtins' key will be inserted to the dictionary:

>>> eval("print('__builtins__' in globals())", {})
True

(As a result of this behavior, we can use the builtins print() and globals() even if we passed a dictionary without a 'builtins' key to eval().) (cherry picked from commit 225b055)

Co-authored-by: Berker Peksag berker.peksag@gmail.com

miss-islington added a commit that referenced this pull request

Aug 19, 2018

@miss-islington @berkerpeksag

If a globals dictionary without a 'builtins' key is passed to eval(), a 'builtins' key will be inserted to the dictionary:

>>> eval("print('__builtins__' in globals())", {})
True

(As a result of this behavior, we can use the builtins print() and globals() even if we passed a dictionary without a 'builtins' key to eval().) (cherry picked from commit 225b055)

Co-authored-by: Berker Peksag berker.peksag@gmail.com

carljm added a commit to carljm/cpython that referenced this pull request

Aug 19, 2018

@carljm