gh-149474: use Py_fopen in Binary{Reader,Writer} for audit hook and path-like support#149524
Open
maurycy wants to merge 3 commits intopython:mainfrom
Open
gh-149474: use Py_fopen in Binary{Reader,Writer} for audit hook and path-like support#149524maurycy wants to merge 3 commits intopython:mainfrom
Py_fopen in Binary{Reader,Writer} for audit hook and path-like support#149524maurycy wants to merge 3 commits intopython:mainfrom
Conversation
maurycy
commented
May 8, 2026
| reader->fd = -1; /* Explicit initialization for cleanup safety */ | ||
| #endif | ||
|
|
||
| reader->filename = PyMem_Malloc(strlen(filename) + 1); |
Contributor
Author
There was a problem hiding this comment.
There's even no single reader of reader->filename
maurycy
commented
May 8, 2026
| return NULL; | ||
| } | ||
|
|
||
| writer->filename = PyMem_Malloc(strlen(filename) + 1); |
Contributor
Author
There was a problem hiding this comment.
There's even no single reader of writer->filename
Contributor
Author
|
cc @ZeroIntensity @sobolevn (you +1 my comment) |
sobolevn
reviewed
May 8, 2026
| /* Add file descriptor-level hints for better kernel I/O scheduling */ | ||
| #if defined(__linux__) && defined(POSIX_FADV_SEQUENTIAL) | ||
| (void)posix_fadvise(reader->fd, 0, 0, POSIX_FADV_SEQUENTIAL); | ||
| (void)posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL); |
Member
There was a problem hiding this comment.
Question: os_posix_fadvise_impl has two implementation details that this place does not: Py_BEGIN_ALLOW_THREADS is set and async_err = PyErr_CheckSignals() is checked.
Do we need to do this here?
|
|
||
| if (writer->fp) { | ||
| fclose(writer->fp); | ||
| Py_fclose(writer->fp); |
Member
There was a problem hiding this comment.
question: why don't we check the return code here? Because the returned type is void?
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 free
to 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.
As a bonus: PEP 446... so that's a hat-trick: 519 + 578 + 446!
Closes #149474