UnicodeEncodeError in matrix.py
jquast opened this issue · comments
Jeff Quast commented
~% telnet 1984.ws
Trying 88.80.6.213...
Connected to 1984.ws.
Escape character is '^]'.
:: Connected to x/84.
:: See https://github.com/jquast/x84/ for source code.
`
.. :: .
.. .. ::
:: ____ _____ .. /\____ _____ xz(imp)
___ ' __\ /___ __\ /__ ' __\ /_ / /____ ___
+ '---\ \--\ __ \--\ __ \--\ \ /---` +
|% __/ \ / |/ \ / |/ \ / \__ _|
.-- :% /\ ## \ ____ \ __ \ __ ## /\ %: --.
|:: |% \ \_____ /____| /____|/ /___| / / %| ::|
|::: |% \/____|_____/_____|_____/_____|_____/ ___|_____/ / %| :::|
'--- |" /_____/ /_____/ \____\/ \_____\/ %| ---`
+__,-----,_______,-----,__,-------------------,__,-----,___+
.: :: ::
:: >> 1984.ws ' .
'
Login as 'new' to create an account.
Login as 'anonymous' is allowed.
Forgot password? Login as 'reset'.
:: Login: d¡ngo
:: Password:
File "x84/bbs/session.py", line 366, in run
self.runscript(self._script_stack.pop())
File "x84/bbs/session.py", line 708, in runscript
value = module.main(*script.args, **script.kwargs)
File "/usr/local/src/x84/x84/default/matrix.py", line 284, in main
do_login(term)
File "/usr/local/src/x84/x84/default/matrix.py", line 250, in do_login
user = authenticate_user(handle, password)
File "/usr/local/src/x84/x84/default/matrix.py", line 189, in authenticate_user
.format(handle=handle))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa1' in position 1: ordinal not in range(128)
stop after general exception in matrix
Connection closed by foreign host.
haliphax commented
Do all of the logger functions just need to use unicode strings, then? Is that the issue? This is the code in question:
log.debug('Failed login for {handle}: no such user.'.format(handle=handle))
Could become:
log.debug(u'Failed login for {handle}: no such user.'.format(handle=handle))
haliphax commented
Actually, upon deeper inspection, this seems to be a problem with the console logger or the formatter's format string. Since the format string is loaded from a file, I'm not sure that it's loaded as unicode.
Jeff Quast commented
Comment removed, sorry @nuklearpony call anytime.