[New-bugs-announce] [issue14777] Tkinter clipboard_get() decodes characters incorrectly

Thomas Kluyver report at bugs.python.org
Fri May 11 00:47:57 CEST 2012


New submission from Thomas Kluyver <takowl at gmail.com>:

With the text 'abc€' copied to the clipboard, on Linux, where UTF-8 is the default encoding:

Python 3.2.3 (default, Apr 12 2012, 21:55:50) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>> root = tkinter.Tk()
>>> root.clipboard_get()
'abcâ\x82¬'
>>> 'abc€'.encode('utf-8').decode('latin-1')
'abcâ\x82¬'

I see the same behaviour in 2.7.3 as well (it returns a unicode string u'abc\xe2\x82\xac').

If the clipboard is only accessible at a bytes level, I think clipboard_get should return a bytes object. But I can reliably copy and paste non-ascii characters between programs, so it looks like it's possible to return unicode.

----------
components: Tkinter
messages: 160378
nosy: takluyver
priority: normal
severity: normal
status: open
title: Tkinter clipboard_get() decodes characters incorrectly
type: behavior
versions: Python 2.7, Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14777>
_______________________________________


More information about the New-bugs-announce mailing list