WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: python2.7.10 unicode  (Read 1639 times)

Offline limeblack

  • Jr. Member
  • **
  • Posts: 69
python2.7.10 unicode
« on: September 22, 2015, 04: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')
« Last Edit: September 22, 2015, 05:13:45 PM by limeblack »

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: python2.7.10 unicode
« Reply #1 on: September 22, 2015, 07: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
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline limeblack

  • Jr. Member
  • **
  • Posts: 69
Re: python2.7.10 unicode
« Reply #2 on: September 23, 2015, 07: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.
« Last Edit: September 23, 2015, 07:46:05 PM by limeblack »

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: python2.7.10 unicode
« Reply #3 on: September 23, 2015, 10:43:41 PM »
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.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."