[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-15 Thread Thomas Kluyver
Thomas Kluyver tak...@gmail.com added the comment: I've submitted the contributor agreement, though I've not yet heard anything back about it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14777

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-15 Thread Thomas Kluyver
Thomas Kluyver tak...@gmail.com added the comment: ...And mere minutes after I said I hadn't heard anything, I've got the confirmation email. :-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14777

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-15 Thread Serhiy Storchaka
Serhiy Storchaka storch...@gmail.com added the comment: ...And mere minutes after I said I hadn't heard anything, I've got the confirmation email. :-) Congratulations! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14777

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-15 Thread Andrew Svetlov
Andrew Svetlov andrew.svet...@gmail.com added the comment: I'm ok with last patch version. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14777 ___

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-15 Thread Roundup Robot
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset f70fa654f70e by Ned Deily in branch '2.7': Issue #14777: In an X11 windowing environment, tkinter may return http://hg.python.org/cpython/rev/f70fa654f70e New changeset 41382250e5e1 by Ned Deily in branch '3.2':

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-15 Thread Ned Deily
Ned Deily n...@acm.org added the comment: Applied for release in 2.7.4, 3.2.4 and 3.3.0. Thanks all! -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-13 Thread Andrew Svetlov
Andrew Svetlov andrew.svet...@gmail.com added the comment: Patch looks good for me, works fine. I think it can be applied to 2.7 as well. There are only problem: I don't know how to make test for it without using external tools like xclip or ctypes bindings for X so library. --

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-13 Thread Thomas Kluyver
Thomas Kluyver tak...@gmail.com added the comment: Indeed, and there don't seem to be any other tests for the clipboard functionality. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14777

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-13 Thread Andrew Svetlov
Andrew Svetlov andrew.svet...@gmail.com added the comment: You are right: there are no tests as well as for the most part of tkinter. Why don't make it if possible? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14777

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-13 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: I'm skeptical about the patch. In both 2.7 and 3.x, clipboard_get returns a Unicode string, yet it fails to decode it properly. So I think this is the bug that ought to be fixed (using the proper encoding). Defaulting to UTF8_STRING is a

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-13 Thread Ned Deily
Ned Deily n...@acm.org added the comment: Martin, is that a way for _tkinter to know whether the result returned from Tcl/Tk is an encoded string or not in this case? With regard to the patch, it would be better to cache the results of the first-time call to get the windowingsystem value so

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-13 Thread Ned Deily
Changes by Ned Deily n...@acm.org: -- Removed message: http://bugs.python.org/msg160554 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14777 ___

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-13 Thread Ned Deily
Ned Deily n...@acm.org added the comment: Martin, is there a way for _tkinter to know whether the result returned from Tcl/Tk is an encoded string or not in this case? With regard to the patch, it would be better to cache the results of the first-time call to get the windowingsystem value so

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-13 Thread Serhiy Storchaka
Serhiy Storchaka storch...@gmail.com added the comment: У пт, 2012-05-11 у 21:25 +, Thomas Kluyver пише: So far, I've not found any case on X where STRING works but UTF8_STRING doesn't. Perhaps there will be problems with the old (very old) closed source software. A few years ago (in

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-13 Thread Thomas Kluyver
Thomas Kluyver tak...@gmail.com added the comment: But the encoding used seemingly depends on the source application - Geany (GTK 2, I think) seemingly sends UTF8 text anyway, whereas Firefox escapes the unicode character. So I don't think we can correctly decode the STRING value in all

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-13 Thread Serhiy Storchaka
Serhiy Storchaka storch...@gmail.com added the comment: But the encoding used seemingly depends on the source application - Geany (GTK 2, I think) seemingly sends UTF8 text anyway, whereas Firefox escapes the unicode character. So I don't think we can correctly decode the STRING value in

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-13 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: Martin, is that a way for _tkinter to know whether the result returned from Tcl/Tk is an encoded string or not in this case? Off-hand, I don't know. I suppose there is a way to do this correctly, but one might have to dig through many

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-13 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: But the encoding used seemingly depends on the source application - Geany (GTK 2, I think) seemingly sends UTF8 text anyway, whereas Firefox escapes the unicode character. So I don't think we can correctly decode the STRING value in all

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-13 Thread Ned Deily
Ned Deily n...@acm.org added the comment: +1 to Martin's proposal -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14777 ___ ___ Python-bugs-list

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-13 Thread Thomas Kluyver
Thomas Kluyver tak...@gmail.com added the comment: OK, I'll produce an updated patch. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14777 ___

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-13 Thread Thomas Kluyver
Thomas Kluyver tak...@gmail.com added the comment: As requested, the second version of the patch (x11-clipboard-try-utf8): - Caches the windowing system per object. The tk call to find the windowing system is made the first time clipboard_get or selection_get are called without specifying

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-13 Thread Ned Deily
Ned Deily n...@acm.org added the comment: Not to bikeshed here but I think it would be better to cache the windowingsystem value at the module level since I assume an application could be calling clipboard_get on different tkinter objects and I don't there is any possibility that the

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-13 Thread Thomas Kluyver
Thomas Kluyver tak...@gmail.com added the comment: I'm happy to put the cache at the module level, but I'll give other people a chance to express their views before I dive into the code again. I imagine most applications would only call clipboard_get() on one item, so it wouldn't matter.

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-13 Thread Serhiy Storchaka
Serhiy Storchaka storch...@gmail.com added the comment: Not to bikeshed here but I think it would be better to cache the windowingsystem value at the module level since I assume an application could be calling clipboard_get on different tkinter objects and I don't there is any possibility

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-13 Thread Thomas Kluyver
Thomas Kluyver tak...@gmail.com added the comment: The 3rd revision of the patch has the cache at the module level. It's a bit awkward, because there's no module level function to call to retrieve it (as far as I know), so it's exposed by objects which can call Tk. Also, serhiy pointed out a

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-13 Thread Ned Deily
Ned Deily n...@acm.org added the comment: Serhiy, I don't know why Misc.Tk is not module level but it isn't so caching global attributes there isn't effective. However, upon further consideration, I take back my original suggestion of caching at the module level primarily because I can think

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-13 Thread Ned Deily
Changes by Ned Deily n...@acm.org: Added file: http://bugs.python.org/file25572/x11-clipboard-try-utf8-4_27.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14777 ___

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-12 Thread Thomas Kluyver
Thomas Kluyver tak...@gmail.com added the comment: Here's a patch that makes UTF8_STRING the default type for clipboard_get and selection_get when running in X11. -- keywords: +patch Added file: http://bugs.python.org/file25552/x11-clipboard-utf8.patch

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-11 Thread Terry J. Reedy
Terry J. Reedy tjre...@udel.edu added the comment: 3.3, Win 7, Idle root.clipboard_get() 'abc€' after cut from here -- nosy: +terry.reedy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14777

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-11 Thread Serhiy Storchaka
Serhiy Storchaka storch...@gmail.com added the comment: This issue can be reproduced by pure Tcl/Tk: $ wish % clipboard get abc? % clipboard get -type STRING abc? % clipboard get -type UTF8_STRING abc€ Use `root.clipboard_get(type='UTF8_STRING')` in Python. I don't know whether it should just

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-11 Thread Thomas Kluyver
Thomas Kluyver tak...@gmail.com added the comment: On this computer, I see this from Tcl: $ wish % clipboard get abc\u20ac But here Python's following suit: root.clipboard_get() 'abc\\u20ac' Which is odd, because as far as I know, my two computers run the same OS (Ubuntu 12.04) in the same

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-11 Thread Ned Deily
Ned Deily n...@acm.org added the comment: As is often the case with Tcl/Tk issues, there are platform differences. On OS X, with the two native Tcl/Tk implementations (Aqua Cocoa and Aqua Carbon), the examples work appear to work as is *and* type UTF8_STRING does not exist. The less

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-11 Thread Thomas Kluyver
Thomas Kluyver tak...@gmail.com added the comment: OK, after a quick bit of reading, I see why I'm confused: the clipboard actually works by requesting the text from the source program, so where you copy it from makes a difference. In my case, copying from firefox gives 'abc\\u20ac', and

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-11 Thread Terry J. Reedy
Terry J. Reedy tjre...@udel.edu added the comment: There are definitely platform differences. As I noted, the original example works fine on Windows. However root.clipboard_get(type='STRING') 'abc€' root.clipboard_get(type='UTF8_STRING') Traceback (most recent call last): File pyshell#21,

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-11 Thread Ned Deily
Ned Deily n...@acm.org added the comment: Most likely the best way to determine the windowing system is to use the tk windowingsystem command (http://www.tcl.tk/man/tcl8.5/TkCmd/tk.htm#M10), so something like this: root = tkinter.Tk() root.call(('tk', 'windowingsystem')) As

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-11 Thread Thomas Kluyver
Thomas Kluyver tak...@gmail.com added the comment: Thanks, Ned. Does it seem like a good idea to test the windowing system like that, and default to UTF8_STRING if it's x11? So far, I've not found any case on X where STRING works but UTF8_STRING doesn't. If it seems reasonable, I'm happy to

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-11 Thread Ned Deily
Ned Deily n...@acm.org added the comment: A patch would be great. I don't have a strong opinion about the issue one way or another. I suppose it would simplify things for Python 3 users if the clipboard results were returned properly in the default case when no 'type' argument is passed to

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-10 Thread Thomas Kluyver
New submission from Thomas Kluyver tak...@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

[issue14777] Tkinter clipboard_get() decodes characters incorrectly

2012-05-10 Thread Serhiy Storchaka
Serhiy Storchaka storch...@gmail.com added the comment: Still worse. I get 'abc?'. Linux, Python 3.1, 3.2, and 3.3, UTF-8 locale. -- nosy: +storchaka versions: +Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14777