This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: UnicodeDecodeError: 'utf8' codec can't decode bytes in position 0-1: illegal encoding
Type: behavior Stage: resolved
Components: Tkinter Versions: Python 3.1
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Tkinter binding involving Control-spacebar raises unicode error
View: 1028
Assigned To: Nosy List: ezio.melotti, wplappert
Priority: low Keywords:

Created on 2009-07-18 08:00 by wplappert, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
tkpy_70.py wplappert, 2009-07-18 08:04
Messages (8)
msg90656 - (view) Author: Winfried Plappert (wplappert) Date: 2009-07-18 08:00
When running the attached program, it will fail with above message on
Control-2 only! All other control keys work happily.

The same program under MS-Windows seems to work (I am under Linux, so I
can't switch easily). 

My version of Python:
Python 3.1 (r31:73572, Jul 18 2009, 08:33:59) 
[GCC 4.3.3] on linux2

uname -a: Linux lin-wpl 2.6.28-13-generic #45-Ubuntu SMP Tue Jun 30
19:49:51 UTC 2009 i686 GNU/Linux

Do I have to replace the line:  
            self.c.bind('<Control-Key-' + str(i) + '>',
                lambda x=str(i): self.key_control_num(x))

with something different? str->unicode, bytes???

This does not help either:
bytes("<Control-Key-" + str(i) + ">", 'utf-8')

This program has been converted via 2to3.
msg90657 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2009-07-18 08:20
Can you paste the full traceback?
I tried to run the script on Windows and nothing happened when I pressed
Ctrl+[0..9].
msg90659 - (view) Author: Winfried Plappert (wplappert) Date: 2009-07-18 08:39
As I said, it does work on Windows, but NOT on Linux!

Her is the full traceback:
wplapper@lin-wpl:~/sudoku/version3.0/tk_test/python3$ python3 tkpy_70.py
key_control_num 1  (# I pressed Control-1)
Traceback (most recent call last):
  File "tkpy_70.py", line 27, in <module>
    app.mainloop()
  File "/usr/local/lib/python3.1/tkinter/__init__.py", line 1009, in
mainloop
    self.tk.mainloop(n)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 0-1:
illegal encoding
msg90663 - (view) Author: Winfried Plappert (wplappert) Date: 2009-07-18 09:16
Is it possible that this issue is related to issue6144?

BTW: I have to handcomile my python 3.1 :)
msg90664 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2009-07-18 09:34
The same problems (ctrl+space and ctrl+2) were reported in #1028.
Closing this as duplicate.
msg90671 - (view) Author: Winfried Plappert (wplappert) Date: 2009-07-18 10:20
I have verified that the problem goes away when you switch from
tcl/tk8.4 to tcl/tk8.5 . Luckily my Ubuntu 9.04 has the 8.5-version
available for install. Thanks for the quick help!
msg90674 - (view) Author: Winfried Plappert (wplappert) Date: 2009-07-18 12:15
wplapper@lin-wpl:~/sudoku/version3.0/tk_test/python3$ python3
Python 3.1 (r31:73572, Jul 18 2009, 11:13:40) 
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>> print(tkinter.Tcl().tk.call('info', 'patchlevel'))
8.5.6
msg90684 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2009-07-18 15:29
Do you know what 8.5.x version were you running before?
You should report it to #1028, apparently they were trying to find out
the affected versions there.
History
Date User Action Args
2022-04-11 14:56:51adminsetgithub: 50761
2009-07-18 15:29:20ezio.melottisetmessages: + msg90684
2009-07-18 12:15:48wplappertsetmessages: + msg90674
2009-07-18 10:20:19wplappertsetmessages: + msg90671
2009-07-18 09:39:51ezio.melottisetsuperseder: Tkinter binding involving Control-spacebar raises unicode error
2009-07-18 09:34:10ezio.melottisetstatus: open -> closed
resolution: duplicate
messages: + msg90664

stage: resolved
2009-07-18 09:16:15wplappertsetmessages: + msg90663
2009-07-18 08:39:40wplappertsetmessages: + msg90659
2009-07-18 08:20:00ezio.melottisetpriority: low

nosy: + ezio.melotti
messages: + msg90657

type: behavior
2009-07-18 08:04:08wplappertsetfiles: + tkpy_70.py
2009-07-18 08:03:36wplappertsetfiles: - tkpy_70.py
2009-07-18 08:03:12wplappertsetfiles: + tkpy_70.py
2009-07-18 08:01:45wplappertsetfiles: - tkpy_70.py
2009-07-18 08:00:18wplappertcreate