summaryrefslogtreecommitdiff
path: root/src/zope/exceptions/log.py
diff options
context:
space:
mode:
authorJason Madden <jamadden@gmail.com>2017-09-11 11:28:00 -0500
committerJason Madden <jamadden@gmail.com>2017-09-11 11:28:00 -0500
commitcc9f097936226845a89d879d49f38894dd032d03 (patch)
tree3643ca6bc8d5d22d2c8927e0cb3686c5698075cf /src/zope/exceptions/log.py
parentd97f1b37d541554ad85e15dd824a84d3e3883f4c (diff)
downloadzope-exceptions-issue1.tar.gz
Fix non-ASCII supplement info under Python 2 and drop Py3.3.issue1
Fixes #1. Fix the coverage environment using zope.testrunner (nose no longer works, that same namespace path issue). Also run the doctests on all supported versions. This requires dropping Python 3.3 because sphinx needs 3.4+.
Diffstat (limited to 'src/zope/exceptions/log.py')
-rw-r--r--src/zope/exceptions/log.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/zope/exceptions/log.py b/src/zope/exceptions/log.py
index 735429a..574ccd3 100644
--- a/src/zope/exceptions/log.py
+++ b/src/zope/exceptions/log.py
@@ -15,13 +15,11 @@
"""
import logging
-try:
- from StringIO import StringIO
-except ImportError: #pragma: no cover Python3
- from io import StringIO
+import io
from zope.exceptions.exceptionformatter import print_exception
+Buffer = io.StringIO if bytes is not str else io.BytesIO
class Formatter(logging.Formatter):
@@ -30,7 +28,7 @@ class Formatter(logging.Formatter):
Uses zope.exceptions.exceptionformatter to generate the traceback.
"""
- sio = StringIO()
+ sio = Buffer()
print_exception(ei[0], ei[1], ei[2], file=sio, with_filenames=True)
s = sio.getvalue()
if s.endswith("\n"):