https://github.com/python/cpython/commit/79b532701e2fe52563baf069494151a332d92b97
commit: 79b532701e2fe52563baf069494151a332d92b97
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-08-13T09:50:19Z
summary:

[3.13] gh-102967: Don't pass None to seek(), simply truncate from the current 
position (GH-102968) (GH-155666)

(cherry picked from commit 7586115ce3adeb9133717f0a721fb05621dd6700)

Co-authored-by: aaron-fl <[email protected]>

files:
A Misc/NEWS.d/next/Library/2023-03-23-19-47-05.gh-issue-102967.gfIYkN.rst
M Lib/doctest.py
M Misc/ACKS

diff --git a/Lib/doctest.py b/Lib/doctest.py
index acdf3ed750a9bd..7027a3dc79dc33 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -289,7 +289,8 @@ def getvalue(self):
         return result
 
     def truncate(self, size=None):
-        self.seek(size)
+        if size is not None:
+            self.seek(size)
         StringIO.truncate(self)
 
 # Worst-case linear-time ellipsis matching.
diff --git a/Misc/ACKS b/Misc/ACKS
index adf13cf6bdb4a5..1c80befe38c2f3 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -416,6 +416,7 @@ Lars Damerow
 Evan Dandrea
 Eric Daniel
 Scott David Daniels
+Aaron Davidson
 Derzsi Dániel
 Lawrence D'Anna
 Ben Darnell
diff --git 
a/Misc/NEWS.d/next/Library/2023-03-23-19-47-05.gh-issue-102967.gfIYkN.rst 
b/Misc/NEWS.d/next/Library/2023-03-23-19-47-05.gh-issue-102967.gfIYkN.rst
new file mode 100644
index 00000000000000..677b8ee86e6c8f
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2023-03-23-19-47-05.gh-issue-102967.gfIYkN.rst
@@ -0,0 +1,2 @@
+A bug in :func:`!doctest._SpoofOut.truncate` was causing None to be passed to 
:func:`!StringIO.seek` when no size was given.
+A simple fix skips the seek call when no size is given so the buffer can be 
truncated from the current position.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to