diff --git a/Lib/_pyio.py b/Lib/_pyio.py index 14961c39d3541d..8e76ceae66e01a 100644 --- a/Lib/_pyio.py +++ b/Lib/_pyio.py @@ -2471,8 +2471,7 @@ def _reset_encoder(position): else: encoder.reset() - if self.closed: - raise ValueError("tell on closed file") + self._checkClosed() if not self._seekable: raise UnsupportedOperation("underlying stream is not seekable") if whence == SEEK_CUR: diff --git a/Misc/NEWS.d/next/Library/2025-01-15-23-51-44.gh-issue-128852.89wrex.rst b/Misc/NEWS.d/next/Library/2025-01-15-23-51-44.gh-issue-128852.89wrex.rst new file mode 100644 index 00000000000000..f213a59ec1e0ce --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-01-15-23-51-44.gh-issue-128852.89wrex.rst @@ -0,0 +1,2 @@ +Fix the :exc:`ValueError` message when calling :meth:`~io.TextIOWrapper.seek` +on a closed :class:`!_pyio.TextIOWrapper`.