Permalink
Browse files

Align "format_traceback" output with built-in function (#64)

  • Loading branch information...
Delgan committed Jan 10, 2019
1 parent c170bf6 commit f10e1fb1540d5241e658a632f9eae6f52af15084
Showing with 5 additions and 4 deletions.
  1. +2 −2 better_exceptions/__init__.py
  2. +2 −1 better_exceptions/formatter.py
  3. +1 −1 better_exceptions/log.py
@@ -46,11 +46,11 @@ def format_exception(exc, value, tb):
# Rebuild each time to take into account any changes made by the user to the global parameters
formatter = ExceptionFormatter(colored=SUPPORTS_COLOR, theme=THEME, max_length=MAX_LENGTH,
pipe_char=PIPE_CHAR, cap_char=CAP_CHAR)
return formatter.format_exception(exc, value, tb)
return list(formatter.format_exception(exc, value, tb))


def excepthook(exc, value, tb):
formatted = format_exception(exc, value, tb)
formatted = u''.join(format_exception(exc, value, tb))
write_stream(formatted, STREAM)


@@ -315,4 +315,5 @@ def _format_exception(self, value, tb, seen=None):
yield u''.join(title).strip() + u'\n'

def format_exception(self, exc, value, tb):
return u''.join(formatted for formatted in self._format_exception(value, tb))
for line in self._format_exception(value, tb):
yield line
@@ -9,7 +9,7 @@ def patch():
import logging
from . import format_exception

logging_format_exception = lambda exc_info: format_exception(*exc_info)
logging_format_exception = lambda exc_info: u''.join(format_exception(*exc_info))

if hasattr(logging, '_defaultFormatter'):
logging._defaultFormatter.format_exception = logging_format_exception

0 comments on commit f10e1fb

Please sign in to comment.