]> git.phdru.name Git - dotfiles.git/commitdiff
lib/python/init.py: simplify excepthook using ColoredFile
authorOleg Broytman <phd@phdru.name>
Mon, 25 Jul 2016 20:47:39 +0000 (23:47 +0300)
committerOleg Broytman <phd@phdru.name>
Mon, 25 Jul 2016 20:47:39 +0000 (23:47 +0300)
lib/python/init.py

index 0e33d094ffd5ed895d3ab29214d9ed7002e3bbb5..6a6ff9a8208bda3d0b25858c43d75c2d7c273e33 100644 (file)
@@ -175,9 +175,9 @@ def init():
     def excepthook(etype, evalue, etraceback):
         lines = format_exception(etype, evalue, etraceback)
         pager = Pager()
+        pager.stdout = ColoredFile(pager.stdout, '\033[31m')  # red
         for line in lines:
-            pager.write(
-                '\033[31m' + line.rstrip('\n') + '\033[0m\n')  # red, reset
+            pager.write(line)
         pager.close()
 
     sys.excepthook = excepthook