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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only difference I can think here is that if the setup script has a syntax error, compile would fail so no instruction gets executed. I don't know how
execworks, but it could be the case it gets to execute something before failing... I don't think this is relevant though because the PEP 517 hooks are supposed to be executed in isolated subcommands, so it is fine for the hook to crash.However, I might be failing to see other problems...
Alternatively we could also try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's my understanding that if there is a syntax error, nothing will ever be executed, so no concerns here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An important difference is that — when an exception gets raised — the stacktrace is now broken. The second argument to compile tells python where to find the source code when displaying the stacktrace. That's exactly what #3577 wanted to improve.
Calling compile before exec doesn't seem to have any noticeable effect on performance:
I don't see how that could make any difference. To execute code the code needs to get compiled before. It doesn't matter if compile gets executed explicitly.