Catch unexpected null-byte errors when adding strings to curses

This commit is contained in:
Michael Lazar
2018-04-07 15:20:32 -04:00
parent 39c1b0050f
commit 90178141ee

View File

@@ -275,7 +275,8 @@ class Terminal(object):
text = self.clean(text, n_cols) text = self.clean(text, n_cols)
params = [] if attr is None else [attr] params = [] if attr is None else [attr]
window.addstr(row, col, text, *params) window.addstr(row, col, text, *params)
except curses.error as e: except (curses.error, ValueError) as e:
# window.addstr could raise "ValueError: embedded null byte"
_logger.warning('add_line raised an exception') _logger.warning('add_line raised an exception')
_logger.exception(str(e)) _logger.exception(str(e))