seecr / weightless-core

Weightless supports implementing complete Python programs as co-routines, including protocol stacks, such as the HTTP protocol.
GNU General Public License v2.0
7 stars 2 forks source link

default encoding problem despite utf-8 locale set #2

Open mrkafk opened 10 years ago

mrkafk commented 10 years ago
(w2)d7 192.168.56.101 ~/w2/tmp/weightless-core/weightless/examples % ./httpserver.py
Traceback (most recent call last):
  File "./httpserver.py", line 26, in <module>
    from weightless.core import be
  File "/root/w2/local/lib/python2.7/site-packages/weightless/__init__.py", line 30, in <module>
    assert _getdefaultencoding() == 'utf-8', 'Please ensure that the default encoding is utf-8'
AssertionError: Please ensure that the default encoding is utf-8
(w2)d7 192.168.56.101 ~/w2/tmp/weightless-core/weightless/examples %

Fixed by adding the following to httpserver.py:

import sys
reload(sys)
sys.setdefaultencoding("utf-8")

OS: Debian 7 / x64, installed default utf-8 locale.

(w2)d7 192.168.56.101 ~/w2/tmp/weightless-core/weightless/examples % locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
ejgroene commented 10 years ago

Hi,

Thanks for the trick with 'reload'. That would work around the problem of setdefaultencoding killing itself. I've added this. Upload pending.

Erik

Erik Groeneveld ♦ seecr.nl ♦ +31 624 584 029

On Wed, Aug 21, 2013 at 1:51 PM, mrkafk notifications@github.com wrote:

(w2)d7 192.168.56.101 ~/w2/tmp/weightless-core/weightless/examples % ./httpserver.py Traceback (most recent call last): File "./httpserver.py", line 26, in from weightless.core import be File "/root/w2/local/lib/python2.7/site-packages/weightless/init.py", line 30, in assert _getdefaultencoding() == 'utf-8', 'Please ensure that the default encoding is utf-8' AssertionError: Please ensure that the default encoding is utf-8 (w2)d7 192.168.56.101 ~/w2/tmp/weightless-core/weightless/examples %

Fixed by adding the following to httpserver.py:

import sys reload(sys) sys.setdefaultencoding("utf-8")

OS: Debian 7 / x64, installed default utf-8 locale.

(w2)d7 192.168.56.101 ~/w2/tmp/weightless-core/weightless/examples % locale LANG=en_US.UTF-8 LANGUAGE= LC_CTYPE="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=

— Reply to this email directly or view it on GitHubhttps://github.com/seecr/weightless-core/issues/2 .