8000 gh-126606: don't write incomplete pyc files by cfbolz · Pull Request #126627 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-126606: don't write incomplete pyc files #126627

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

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add parens to error, add comment why I'm using an OSError
  • Loading branch information
cfbolz committed Nov 13, 2024
commit 50f21680a120eb993c51566bd87f4e0d7c9c1b46
4 changes: 3 additions & 1 deletion Lib/importlib/_bootstrap_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ def _write_atomic(path, data, mode=0o666):
with _io.FileIO(fd, 'wb') as file:
bytes_written = file.write(data)
if bytes_written != len(data):
raise OSError("os.write didn't write the full pyc file")
# Raise an OSError so the except below cleans up the partially
# written file.
raise OSError("os.write() didn't write the full pyc file")
_os.replace(path_tmp, path)
except OSError:
try:
Expand Down
0