Skip to content

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Mar 20, 2022

The _SharedFile tracks its own virtual position into the file as
self._pos and updates it after reading or seeking. tell() should
return this position instead of calling into the underlying file object,
since if multiple _SharedFile instances are being used concurrently on
the same file, another one may have moved the real file position.
Additionally, calling into the underlying tell may expose thread
safety issues in the underlying file object because it was called
without taking the lock.
(cherry picked from commit e730ae7)

Co-authored-by: Kevin Mehall km@kevinmehall.net

https://bugs.python.org/issue42369

)

The `_SharedFile` tracks its own virtual position into the file as
`self._pos` and updates it after reading or seeking. `tell()` should
return this position instead of calling into the underlying file object,
since if multiple `_SharedFile` instances are being used concurrently on
the same file, another one may have moved the real file position.
Additionally, calling into the underlying `tell` may expose thread
safety issues in the underlying file object because it was called
without taking the lock.
(cherry picked from commit e730ae7)

Co-authored-by: Kevin Mehall <km@kevinmehall.net>
@miss-islington
Copy link
Contributor Author

@kevinmehall and @serhiy-storchaka: Status check is done, and it's a success ✅ .

@miss-islington miss-islington merged commit 4aa8b80 into python:3.9 Mar 20, 2022
@miss-islington miss-islington deleted the backport-e730ae7-3.9 branch March 20, 2022 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants