Skip to content

Commit 79b5327

Browse files
[3.13] gh-102967: Don't pass None to seek(), simply truncate from the current position (GH-102968) (GH-155666)
(cherry picked from commit 7586115) Co-authored-by: aaron-fl <43595516+aaron-fl@users.noreply.github.com>
1 parent 4fe5490 commit 79b5327

3 files changed

Lines changed: 5 additions & 1 deletion

File tree

Lib/doctest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ def getvalue(self):
289289
return result
290290

291291
def truncate(self, size=None):
292-
self.seek(size)
292+
if size is not None:
293+
self.seek(size)
293294
StringIO.truncate(self)
294295

295296
# Worst-case linear-time ellipsis matching.

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ Lars Damerow
416416
Evan Dandrea
417417
Eric Daniel
418418
Scott David Daniels
419+
Aaron Davidson
419420
Derzsi Dániel
420421
Lawrence D'Anna
421422
Ben Darnell
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
A bug in :func:`!doctest._SpoofOut.truncate` was causing None to be passed to :func:`!StringIO.seek` when no size was given.
2+
A simple fix skips the seek call when no size is given so the buffer can be truncated from the current position.

0 commit comments

Comments
 (0)