>>Me:
>> I asked what kinds of bytes are accepted as tkinter parameters.
>> I still wonder why they are accepted at all.
>> Does anyone know a reason for this
>> or has a link to some relevant discussion?
>Terry Reedy:
> I do not remember any particular public discussion of tkinter on the dev 
> lists. I suspect the reason is a) avoid breaking old code and b) tkinter 
> (tk inter-face) passes params on to tk which expects byte strings. I 
> would not be surprised if tkinter has to encode py3 (unicode) strings 
> before passing them on.

If I interpret the code in _tkinter.c correctly
Python bytes are converted to a String Tcl_Obj
and Python str to a Unicode Tcl_Obj:

AsObj(PyObject *value)
{
...
        if (PyBytes_Check(value))
                return Tcl_NewStringObj(PyBytes_AS_STRING(value),
                                        PyBytes_GET_SIZE(value));
...
        else if (PyUnicode_Check(value)) {
...
                return Tcl_NewUnicodeObj(inbuf, size);
...
}

And as Martin pointed out:
>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.

If I don't want bytes to get passed to tkinter
I just have to raise an exception in AsObj, no?
Or is it even sufficient to just remove the bytes case?

Regards and thanks for your answers.
Matthias Kievernagel.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to