Skip to content

Conversation

websurfer5
Copy link
Contributor

@websurfer5 websurfer5 commented Jun 1, 2019

Implement buffered tell() as a wrapper for buffered seek(0, io.SEEK_CUR) to fix a problem with the internally maintained file position getting out of sync with the kernel when using read/write append mode. The fix applies to both binary and text files.

https://bugs.python.org/issue36411

text file for read/write append. This is required for Windows systems.
@csabella csabella requested a review from benjaminp June 1, 2019 11:03
@brettcannon brettcannon added the type-bug An unexpected behavior, bug, or error label Jun 3, 2019
Copy link
Contributor

@benjaminp benjaminp left a comment

Choose a reason for hiding this comment

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

Won't this break calling tell() on buffered streams wrapping raw io that supports tell() but not seek()?

*/

CHECK_INITIALIZED(self)
PyObject *z_obj = PyLong_FromLong(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like it leaks a reference to z_obj.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@pewscorner
Copy link
Contributor

Wouldn't it be possible to use the old buffered_tell() code if the stream doesn't support seek()? As far as I know, the bug only happens after seeking, so it ought to be fine to fall back to the old approach when seeking isn't possible, I would imagine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting changes type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants