-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
bpo-36411: Python 3 f.tell() gets out of sync with file pointer in binary append+read mode #13717
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
base: main
Are you sure you want to change the base?
Conversation
seek(0, io.SEEK_CUR)
text file for read/write append. This is required for Windows systems.
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.
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); |
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 looks like it leaks a reference to z_obj.
|
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 |
|
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. |
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