[affich_tools] debug sur des UnicodeDecodeError

This commit is contained in:
Valentin Samir 2013-11-20 00:47:34 +01:00
parent 248d199838
commit b035507bf6

View file

@ -278,7 +278,11 @@ def prompt(prompt, defaut='', couleur='gras'):
if defaut :
sys.stdout.write((" [%s]" % defaut).encode(encoding))
sys.stdout.write(" ".encode(encoding))
v = sys.stdin.readline().decode(encoding).strip()
v = sys.stdin.readline()
try:
v = v.decode(encoding).strip()
except UnicodeDecodeError as error:
raise UnicodeDecodeError("%s: %r" % (error, v))
if not v: v = defaut
return v