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
bpo-20082: fix misbehavior of buffered writes to raw files in append mode #21729
base: main
Are you sure you want to change the base?
Conversation
|
Hmm, this seems to suddenly be causing some failures I didn't expect :/ |
| @@ -1795,6 +1827,8 @@ _io_BufferedWriter___init___impl(buffered *self, PyObject *raw, | |||
| self->readable = 0; | |||
| self->writable = 1; | |||
|
|
|||
| _bufferedwriter_set_append(self); | |||
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.
This call should be checked for failure.
| @@ -2309,6 +2351,8 @@ _io_BufferedRandom___init___impl(buffered *self, PyObject *raw, | |||
| self->readable = 1; | |||
| self->writable = 1; | |||
|
|
|||
| _bufferedwriter_set_append(self); | |||
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.
This call should be checked for failure.
| @@ -1767,6 +1778,27 @@ _bufferedwriter_reset_buf(buffered *self) | |||
| self->write_end = -1; | |||
| } | |||
|
|
|||
| static void | |||
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.
This function should be checked for failure, so it should not return void.
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.
I'm not so sure. What is its failure state? It either sets self->appending = 1 or self->appending = 0. Neither case represents a failure or success. AFAICT all calls within it check for failure or success and are handled appropriately.
|
Resolved all the trivial code style issues. Remaining question is whether I think the issue that was causing test failures is fixed. |
|
Hmm, now the CI systems are all consistently showing a new test failure, but I cannot reproduce it locally even with the exact same test command they're running. Update: I can reproduce them now by configuring |
if the raw file is appending there is no reason to attempt to rewind it before flushing
…t have a mode attribute) and ensure that the mode is in fact a string
|
I think this is ready now for the next round of review. Not sure why the Azure pipeline failed but it doesn't seem related. |
This is a patch for a bug I apparently wrote many years ago but never converted to a PR.
https://bugs.python.org/issue20082