Uh oh!
There was an error while loading. Please reload this page.
Add __builtins__ to globals argument of py::exec and py::eval if not present - #2616
Merged
Conversation
bstaletic
approved these changes
Oct 23, 2020
henryiii
approved these changes
Oct 24, 2020
bstaletic
commented
Oct 25, 2020
Collaborator
Fixes #1654 as well. |
martinRenou
commented
Oct 27, 2020
Contributor
Thanks a lot @YannickJadoul |
rwgk
approved these changes
Oct 27, 2020
rwgk
left a comment
Collaborator
There was a problem hiding this comment.
This looks good to me as-is, but what do you think about moving the new code into inline void detail::ensure_global_contains_builtins()? That way you'd only need one #if (inside that function).
YannickJadoul
commented
Oct 27, 2020
CollaboratorAuthor
I'm not entirely convinced on which side to pick here. On a high level, definitely, avoid code duplication. In practice ... I'm a bit in doubt whether it looks better. But I guess it also doesn't look worse. |
YannickJadoul
commented
Oct 27, 2020
CollaboratorAuthor
One or two reviews of this last commit, please? |
bstaletic
approved these changes
Oct 27, 2020
YannickJadoul
commented
Oct 27, 2020
CollaboratorAuthor
Thanks, all! |
10 tasks
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
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Python (even 2.7!) adds
__builtins__when callingexecoreval:For the C API's
PyRun_String, this only happens since Python 3.8 (python/cpython#13362; see #1091 (comment)). It would make sense to me to backport/downport/sideport/port this to pybind11 on all versions of Python, for the sake of consistency. No?Closes#1091
Closes#2557
Closes#1654 (thanks, @bstaletic!)
Suggested changelog entry: