Skip to content

UnicodeDecodeError: 'utf8' codec can't decode bytes in position 0-1: illegal encoding #50761

Closed

Description

@wplappert
mannequin
BPO 6512
Nosy @ezio-melotti
Superseder
  • bpo-1028: Tkinter binding involving Control-spacebar raises unicode error
  • Files
  • tkpy_70.py
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2009-07-18.09:34:10.109>
    created_at = <Date 2009-07-18.08:00:18.728>
    labels = ['type-bug', 'expert-tkinter']
    title = "UnicodeDecodeError: 'utf8' codec can't decode bytes in position 0-1: illegal encoding"
    updated_at = <Date 2009-07-18.15:29:20.577>
    user = 'https://bugs.python.org/wplappert'

    bugs.python.org fields:

    activity = <Date 2009-07-18.15:29:20.577>
    actor = 'ezio.melotti'
    assignee = 'none'
    closed = True
    closed_date = <Date 2009-07-18.09:34:10.109>
    closer = 'ezio.melotti'
    components = ['Tkinter']
    creation = <Date 2009-07-18.08:00:18.728>
    creator = 'wplappert'
    dependencies = []
    files = ['14519']
    hgrepos = []
    issue_num = 6512
    keywords = []
    message_count = 8.0
    messages = ['90656', '90657', '90659', '90663', '90664', '90671', '90674', '90684']
    nosy_count = 2.0
    nosy_names = ['ezio.melotti', 'wplappert']
    pr_nums = []
    priority = 'low'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '1028'
    type = 'behavior'
    url = 'https://bugs.python.org/issue6512'
    versions = ['Python 3.1']

    Activity

    1. wplappert commented on Jul 18, 2009

      wplappertmannequin
      MannequinAuthor

      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.

    2. ezio-melotti commented on Jul 18, 2009

      @ezio-melotti
      Member

      Can you paste the full traceback?
      I tried to run the script on Windows and nothing happened when I pressed
      Ctrl+[0..9].

    3. wplappert commented on Jul 18, 2009

      wplappertmannequin
      MannequinAuthor

      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
    4. wplappert commented on Jul 18, 2009

      wplappertmannequin
      MannequinAuthor

      Is it possible that this issue is related to bpo-6144?

      BTW: I have to handcomile my python 3.1 :)

    5. ezio-melotti commented on Jul 18, 2009

      @ezio-melotti
      Member

      The same problems (ctrl+space and ctrl+2) were reported in bpo-1028.
      Closing this as duplicate.

    6. wplappert commented on Jul 18, 2009

      wplappertmannequin
      MannequinAuthor

      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!

    7. wplappert commented on Jul 18, 2009

      wplappertmannequin
      MannequinAuthor
      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
    8. ezio-melotti commented on Jul 18, 2009

      @ezio-melotti
      Member

      Do you know what 8.5.x version were you running before?
      You should report it to bpo-1028, apparently they were trying to find out
      the affected versions there.

    9. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions