summaryrefslogtreecommitdiffstats
path: root/Modules/_tkinter.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-04-02 07:58:40 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-04-02 07:58:40 (GMT)
commitb452f41cc82a9627d9a29b5ff6853af06ed3083f (patch)
tree3fa7bb1668df279bfa8b08ce33f6072238182394 /Modules/_tkinter.c
parent1399a01b903a6cdf2ecd9d8e479197d94b8b721c (diff)
parentf7de3dd02d5186f30f69b80f5ee00376581f1d23 (diff)
downloadcpython-b452f41cc82a9627d9a29b5ff6853af06ed3083f.zip
cpython-b452f41cc82a9627d9a29b5ff6853af06ed3083f.tar.gz
cpython-b452f41cc82a9627d9a29b5ff6853af06ed3083f.tar.bz2
Issue #21526: Fixed support of new boolean type in Tcl 8.5.
Diffstat (limited to 'Modules/_tkinter.c')
-rw-r--r--Modules/_tkinter.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
index 4bced69..403cd71 100644
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -998,6 +998,15 @@ AsObj(PyObject *value)
}
}
+static PyObject *
+fromBoolean(PyObject* tkapp, Tcl_Obj *value)
+{
+ int boolValue;
+ if (Tcl_GetBooleanFromObj(Tkapp_Interp(tkapp), value, &boolValue) == TCL_ERROR)
+ return Tkinter_Error(tkapp);
+ return PyBool_FromLong(boolValue);
+}
+
static PyObject*
FromObj(PyObject* tkapp, Tcl_Obj *value)
{
@@ -1011,10 +1020,7 @@ FromObj(PyObject* tkapp, Tcl_Obj *value)
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);
+ return fromBoolean(tkapp, value);
}
if (value->typePtr == app->ByteArrayType) {
@@ -1069,6 +1075,15 @@ FromObj(PyObject* tkapp, Tcl_Obj *value)
Tcl_GetCharLength(value));
}
+#if TK_VERSION_HEX >= 0x08050000
+ if (app->BooleanType == NULL &&
+ strcmp(value->typePtr->name, "booleanString") == 0) {
+ /* booleanString type is not registered in Tcl */
+ app->BooleanType = value->typePtr;
+ return fromBoolean(tkapp, value);
+ }
+#endif
+
return newPyTclObject(value);
}