# set displayhook and excepthook
from pprint import pprint
+ from traceback import format_exception, print_exc
+
pager = os.environ.get("PAGER") or 'more'
# if your pager is 'less', options '-F' and '-R' must be passed to it,
if value is not None:
builtins._ = value
pager = Pager()
- pager.pprint(value)
+ try:
+ pager.pprint(value)
+ except:
+ pager.stdout = ColoredFile(pager.stdout, '\033[31m') # red
+ print_exc(file=pager)
pager.close()
sys.displayhook = displayhook
- from traceback import format_exception
-
def excepthook(etype, evalue, etraceback):
lines = format_exception(etype, evalue, etraceback)
pager = Pager()