Skip to content

Commit e174896

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

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
@@ -291,7 +291,8 @@ def getvalue(self):
291291
return result
292292

293293
def truncate(self, size=None):
294-
self.seek(size)
294+
if size is not None:
295+
self.seek(size)
295296
StringIO.truncate(self)
296297

297298
# Worst-case linear-time ellipsis matching.

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ Lars Damerow
419419
Evan Dandrea
420420
Eric Daniel
421421
Scott David Daniels
422+
Aaron Davidson
422423
Derzsi Dániel
423424
Lawrence D'Anna
424425
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)