[Python-3000] IDLE encoding setup

Neal Norwitz nnorwitz at gmail.com
Sun Aug 12 04:49:12 CEST 2007


On 8/11/07, Kurt B. Kaiser <kbk at shore.net> wrote:
> I've checked in a version of PyShell.py which directs exceptions to the
> terminal instead of to IDLE's shell since the latter isn't working right now.
>
> There also is apparently an encoding issue with the subprocess setup
> which I'm ignoring for now by starting IDLE w/o the subprocess:
>
> cd Lib/idlelib
> ../../python ./idle.py -n
>
> Traceback (most recent call last):
>   File "./idle.py", line 21, in <module>
>     idlelib.PyShell.main()
>   File "/home/kbk/PYDOTORG/projects/python/branches/py3k/Lib/idlelib/PyShell.py", line 1389, in main
>     shell = flist.open_shell()
>   File "/home/kbk/PYDOTORG/projects/python/branches/py3k/Lib/idlelib/PyShell.py", line 274, in open_shell
>     if not self.pyshell.begin():
>   File "/home/kbk/PYDOTORG/projects/python/branches/py3k/Lib/idlelib/PyShell.py", line 976, in begin
>     self.firewallmessage, idlever.IDLE_VERSION, nosub))
>   File "/home/kbk/PYDOTORG/projects/python/branches/py3k/Lib/idlelib/PyShell.py", line 1214, in write
>     OutputWindow.write(self, s, tags, "iomark")
>   File "/home/kbk/PYDOTORG/projects/python/branches/py3k/Lib/idlelib/OutputWindow.py", line 42, in write
>     s = str(s, IOBinding.encoding)
> TypeError: decoding Unicode is not supported

I can't reproduce this problem in idle.  Here's how the error seems to
be caused:

>>> str('abc', 'utf-8')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: decoding Unicode is not supported

Also:

>>> str(str('abc', 'utf-8'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: decoding Unicode is not supported

This hack might work to get you farther:

    s = str(s.encode('utf-8'), IOBinding.encoding)

(ie, add the encode() part)  I don't know what should be done to
really fix it though.

n


More information about the Python-3000 mailing list