Skip to content

Conversation

@brandtbucher
Copy link
Member

@brandtbucherbrandtbucher commented May 11, 2024

Write to a temporary file first, then rename it to the intended jit_stencils.h file. This keeps other build steps from assuming that the file has been successfully generated when it's still in the process of being written.

CC: @savannahostrowski

@brandtbucherbrandtbucher added type-bug An unexpected behavior, bug, or error build The build process and cross-build needs backport to 3.13 bugs and security fixes labels May 11, 2024
@brandtbucherbrandtbucher self-assigned this May 11, 2024
Copy link
Member

@savannahostrowskisavannahostrowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this LGTM. Just one comment.

Copy link
Contributor

@hroncokhroncok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change makes perfect sense and should fix the problem. Hard to test due to the nature of the issue, hence untested.

One question though (and one optional suggestion).

file.write(digest)
ifcomment:
file.write(f"// {comment}\n\n")
file.write("")
Copy link
Contributor

@hroncokhroncokMay 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely sure what was the purpose of this line, but it is no longer there. I guess it did nothing, correct?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. Yeah, I think this was originally intended to write a newline, but it was really doing nothing. But I think we do want to add a newline whether or not there's a comment, so I'll move one of them from the comment line to here.

file.write(f"{line}\n")
jit_stencils_new.replace(jit_stencils)
finally:
jit_stencils_new.unlink(True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to guess (and look up) what the boolean stands for. Would you mind using a keyword argument instead?

Suggested change
jit_stencils_new.unlink(True)
jit_stencils_new.unlink(missing_ok=True)

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, good suggestion.

@brandtbucherbrandtbucher merged commit 4702b7b into python:mainMay 16, 2024
@miss-islington-app
Copy link

Thanks @brandtbucher for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 16, 2024
…ythonGH-118957) (cherry picked from commit 4702b7b) Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
@bedevere-app
Copy link

GH-119101 is a backport of this pull request to the 3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13 bugs and security fixes label May 16, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

buildThe build process and cross-buildtopic-JITtype-bugAn unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@brandtbucher@hroncok@savannahostrowski