Fix #2299 (invalid characters causing a TB)

any character beyond 0x110000 does not exist and should be dropped
This commit is contained in:
mathieui 2013-06-04 13:20:59 +02:00
parent 0abc789403
commit ae009318b2

View file

@ -92,6 +92,9 @@ def get_char_list_new(s):
except curses.error:
# No input, this means a timeout occurs.
return ret_list
except ValueError: # invalid input
log.debug('Invalid character entered.')
return ret_list
s.timeout(0)
if isinstance(key, int):
ret_list.append(curses.keyname(key).decode())
@ -104,6 +107,9 @@ def get_char_list_new(s):
part = s.get_wch()
except curses.error:
pass
except ValueError: # invalid input
log.debug('Invalid character entered.')
pass
else:
key = 'M-%s' % part
# and an even more special case for keys like
@ -114,6 +120,9 @@ def get_char_list_new(s):
part = s.get_wch()
except curses.error:
pass
except ValueError:
log.debug('Invalid character entered.')
pass
else:
key = '%s-%s' % (key, part)
if key == '\x7f' or key == '\x08':