diff --git a/Lib/doctest.py b/Lib/doctest.py index e02e73ed722f7e..02144cd544e80c 100644 --- a/Lib/doctest.py +++ b/Lib/doctest.py @@ -288,7 +288,8 @@ def getvalue(self): return result def truncate(self, size=None): - self.seek(size) + if size != None: + self.seek(size) StringIO.truncate(self) # Worst-case linear-time ellipsis matching. diff --git a/Misc/ACKS b/Misc/ACKS index 25542d01de695c..f530ae1f0a56b6 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -419,6 +419,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..bcece939531869 --- /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.