From ecc40fdc5efc873f87ff10f313f3045dbdf70363 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 13 May 2012 19:01:27 +0200 Subject: Catch a possible exception when trying to retrieve the rgb value in curses Fixes #2354 --- src/xhtml.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/xhtml.py b/src/xhtml.py index cf7a5fc0..38ec690c 100644 --- a/src/xhtml.py +++ b/src/xhtml.py @@ -206,7 +206,10 @@ def ncurses_color_to_html(color): html color. """ if color <= 15: - (r, g, b) = curses.color_content(color) + try: + (r, g, b) = curses.color_content(color) + except: # fallback in faulty terminals (e.g. xterm) + (r, g, b) = curses.color_content(color%8) r = r / 1000 * 6 - 0.01 g = g / 1000 * 6 - 0.01 b = b / 1000 * 6 - 0.01 -- cgit v1.2.3