[#3583] Fix encoding error with `print` statements in doctests

This fix was suggested by Stack Overflow user phd in
<https://stackoverflow.com/a/50863820/744178>.
This commit is contained in:
John T. Wodder II 2018-06-14 19:05:07 +00:00
parent 5221a14764
commit d382f3e77f
2 changed files with 2 additions and 1 deletions

View File

@ -0,0 +1 @@
Fix encoding error with `print` statements in doctests

View File

@ -505,7 +505,7 @@ def _fix_spoof_python2(runner, encoding):
def getvalue(self):
result = _SpoofOut.getvalue(self)
if encoding:
if encoding and isinstance(result, bytes):
result = result.decode(encoding)
return result