Tiny Core Linux

Tiny Core Extensions => TCE Bugs => Topic started by: limeblack on September 22, 2015, 07:39:31 PM

Title: python2.7.10 unicode
Post by: limeblack on September 22, 2015, 07:39:31 PM
Could someone please fix the python tcz so that it sets the default encoding to unicode.

There are several different ways to do it according to the following http://www.ianbicking.org/illusive-setdefaultencoding.html

I edited the following file to get it to work

rm /usr/local/lib/python2.7/SocketServer.py
cp /tmp/tcloop/python/usr/local/lib/python2.7/SocketServer.py /usr/local/lib/python2.7/SocketSerever.py

Then you remove `import sys` from `/usr/local/lib/python2.7/SocketServer.py` and add the following to the top

import sys
reload(sys)
sys.setdefaultencoding('utf8')
Title: Re: python2.7.10 unicode
Post by: bmarkus on September 22, 2015, 10:52:15 PM
It is really a bad idea to change default behaviour of Python, it would cause many problems, so no sense to change the extension in the repo for that.

If you need a hacked version, hack yourself your own copy. But much better to move to Python 3.4 or 3.5
Title: Re: python2.7.10 unicode
Post by: limeblack on September 23, 2015, 10:26:10 PM
@bmarkus
Unicode is the default in Python 3.

Unicode is backwards compatible with ascii.  'ascii' is the current default.

In my opinion this a bug unless you can give an example where it breaks code.
Title: Re: python2.7.10 unicode
Post by: bmarkus on September 24, 2015, 01:43:41 AM
Opening post was a request to patch Python 2.7.10 in the repo to change default encoding. It can brake many existing applications expecting str type and converting it to other type. If a Python script need a patched Python through it away or fix. But do not patch Python itself even not for yourself.  It has nothing to do with examples requested.