py3 tkinter acceps bytes. why?

Martin v. Loewis martin at v.loewis.de
Tue May 4 17:29:06 EDT 2010


> In a recent thread named "py3 tkinter Text accepts what bytes?"
> (google groups link:
> http://groups.google.com/group/comp.lang.python/browse_thread/thread/b75ed69f4e81b202/e2aff9ddd62d210c?lnk=raot)
> I asked what kinds of bytes are accepted as tkinter parameters.
> I still wonder why they are accepted at all.

That's basically because the port from 2.x was shallow: it supports the
exact same feature set that 2.x supports, with just the type names swapped.

Tkinter in 2.x will already use Unicode strings in most situations.
However, 2.x code would often also provide byte strings for text
properties, and Tcl supports that "nicely" (*)

Regards,
Martin

(*) I think you also asked how Tcl interprets things. IIUC, it first
assumes that a byte string is UTF-8 (starting from 8.1 or so); if it's
not, it then assumes that it's in the locale's encoding. If that turns
out incorrect also, it just tries to pass it as-is to the operating
system GUI API. Or something like that.



More information about the Python-list mailing list