#8471: reset _SpoofOut.buf to an empty string when truncating; if Unicode had been output previously, it had been coerced to a Unicode string, potentially making subsequent prints behave differently or raise UnicodeErrors.
diff --git a/Lib/doctest.py b/Lib/doctest.py
index 70d3359..917684c 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -263,6 +263,9 @@
StringIO.truncate(self, size)
if hasattr(self, "softspace"):
del self.softspace
+ if not self.buf:
+ # Reset it to an empty string, to make sure it's not unicode.
+ self.buf = ''
# Worst-case linear-time ellipsis matching.
def _ellipsis_match(want, got):