jquast / x84

A python telnet/ssh server for modern terminals. In spirit of classic software such as ami/x, teleguard, renegade, iniquity.

Home Page:http://x84.readthedocs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UnicodeEncodeError in matrix.py

jquast opened this issue · comments

~% 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.

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))

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.

Comment removed, sorry @nuklearpony call anytime.