Skip to content

Commit 7586115

Browse files
authored
gh-102967: Don't pass None to seek(), simply truncate from the current position (GH-102968)
1 parent 296f016 commit 7586115

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
@@ -285,7 +285,8 @@ def getvalue(self):
285285
return result
286286

287287
def truncate(self, size=None):
288-
self.seek(size)
288+
if size is not None:
289+
self.seek(size)
289290
StringIO.truncate(self)
290291

291292
# Worst-case linear-time ellipsis matching.

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ Hauke Dämpfling
426426
Evan Dandrea
427427
Eric Daniel
428428
Scott David Daniels
429+
Aaron Davidson
429430
Derzsi Dániel
430431
Lawrence D'Anna
431432
Steven D'Aprano
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)