diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-03-22 22:47:45 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-03-22 22:47:45 (GMT) |
commit | f07a4b663daafaf792ea39e118345fa1f10bbf8f (patch) | |
tree | e2a73813080e2a2bab491d886b0c6af2ece288a2 /Modules | |
parent | 1b2f4d5f0c015c01f445432c10eadb24d0805a28 (diff) | |
download | cpython-f07a4b663daafaf792ea39e118345fa1f10bbf8f.zip cpython-f07a4b663daafaf792ea39e118345fa1f10bbf8f.tar.gz cpython-f07a4b663daafaf792ea39e118345fa1f10bbf8f.tar.bz2 |
Issue #21526: Tkinter now supports new boolean type in Tcl 8.5.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_tkinter.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index 52069ec..4bced69 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -229,6 +229,7 @@ typedef struct { int dispatching; /* We cannot include tclInt.h, as this is internal. So we cache interesting types here. */ + const Tcl_ObjType *OldBooleanType; const Tcl_ObjType *BooleanType; const Tcl_ObjType *ByteArrayType; const Tcl_ObjType *DoubleType; @@ -585,7 +586,8 @@ Tkapp_New(const char *screenName, const char *className, } #endif - v->BooleanType = Tcl_GetObjType("boolean"); + v->OldBooleanType = Tcl_GetObjType("boolean"); + v->BooleanType = Tcl_GetObjType("booleanString"); v->ByteArrayType = Tcl_GetObjType("bytearray"); v->DoubleType = Tcl_GetObjType("double"); v->IntType = Tcl_GetObjType("int"); @@ -1001,15 +1003,18 @@ FromObj(PyObject* tkapp, Tcl_Obj *value) { PyObject *result = NULL; TkappObject *app = (TkappObject*)tkapp; + Tcl_Interp *interp = Tkapp_Interp(tkapp); if (value->typePtr == NULL) { return unicodeFromTclStringAndSize(value->bytes, value->length); } - if (value->typePtr == app->BooleanType) { - result = value->internalRep.longValue ? Py_True : Py_False; - Py_INCREF(result); - return result; + if (value->typePtr == app->BooleanType || + value->typePtr == app->OldBooleanType) { + int boolValue; + if (Tcl_GetBooleanFromObj(interp, value, &boolValue) == TCL_ERROR) + return Tkinter_Error(tkapp); + return PyBool_FromLong(boolValue); } if (value->typePtr == app->ByteArrayType) { @@ -1032,15 +1037,14 @@ FromObj(PyObject* tkapp, Tcl_Obj *value) PyObject *elem; Tcl_Obj *tcl_elem; - status = Tcl_ListObjLength(Tkapp_Interp(tkapp), value, &size); + status = Tcl_ListObjLength(interp, value, &size); if (status == TCL_ERROR) return Tkinter_Error(tkapp); result = PyTuple_New(size); if (!result) return NULL; for (i = 0; i < size; i++) { - status = Tcl_ListObjIndex(Tkapp_Interp(tkapp), - value, i, &tcl_elem); + status = Tcl_ListObjIndex(interp, value, i, &tcl_elem); if (status == TCL_ERROR) { Py_DECREF(result); return Tkinter_Error(tkapp); |