Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f07a4b6

Browse files
Issue #21526: Tkinter now supports new boolean type in Tcl 8.5.
1 parent 1b2f4d5 commit f07a4b6

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Core and Builtins
2323
Library
2424
-------
2525

26+
- Issue #21526: Tkinter now supports new boolean type in Tcl 8.5.
27+
2628
- Issue #23647: Increase impalib's MAXLINE to accommodate modern mailbox sizes.
2729

2830
- Issue #23539: If body is None, http.client.HTTPConnection.request now sets

Modules/_tkinter.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ typedef struct {
229229
int dispatching;
230230
/* We cannot include tclInt.h, as this is internal.
231231
So we cache interesting types here. */
232+
const Tcl_ObjType *OldBooleanType;
232233
const Tcl_ObjType *BooleanType;
233234
const Tcl_ObjType *ByteArrayType;
234235
const Tcl_ObjType *DoubleType;
@@ -585,7 +586,8 @@ Tkapp_New(const char *screenName, const char *className,
585586
}
586587
#endif
587588

588-
v->BooleanType = Tcl_GetObjType("boolean");
589+
v->OldBooleanType = Tcl_GetObjType("boolean");
590+
v->BooleanType = Tcl_GetObjType("booleanString");
589591
v->ByteArrayType = Tcl_GetObjType("bytearray");
590592
v->DoubleType = Tcl_GetObjType("double");
591593
v->IntType = Tcl_GetObjType("int");
@@ -1001,15 +1003,18 @@ FromObj(PyObject* tkapp, Tcl_Obj *value)
10011003
{
10021004
PyObject *result = NULL;
10031005
TkappObject *app = (TkappObject*)tkapp;
1006+
Tcl_Interp *interp = Tkapp_Interp(tkapp);
10041007

10051008
if (value->typePtr == NULL) {
10061009
return unicodeFromTclStringAndSize(value->bytes, value->length);
10071010
}
10081011

1009-
if (value->typePtr == app->BooleanType) {
1010-
result = value->internalRep.longValue ? Py_True : Py_False;
1011-
Py_INCREF(result);
1012-
return result;
1012+
if (value->typePtr == app->BooleanType ||
1013+
value->typePtr == app->OldBooleanType) {
1014+
int boolValue;
1015+
if (Tcl_GetBooleanFromObj(interp, value, &boolValue) == TCL_ERROR)
1016+
return Tkinter_Error(tkapp);
1017+
return PyBool_FromLong(boolValue);
10131018
}
10141019

10151020
if (value->typePtr == app->ByteArrayType) {
@@ -1032,15 +1037,14 @@ FromObj(PyObject* tkapp, Tcl_Obj *value)
10321037
PyObject *elem;
10331038
Tcl_Obj *tcl_elem;
10341039

1035-
status = Tcl_ListObjLength(Tkapp_Interp(tkapp), value, &size);
1040+
status = Tcl_ListObjLength(interp, value, &size);
10361041
if (status == TCL_ERROR)
10371042
return Tkinter_Error(tkapp);
10381043
result = PyTuple_New(size);
10391044
if (!result)
10401045
return NULL;
10411046
for (i = 0; i < size; i++) {
1042-
status = Tcl_ListObjIndex(Tkapp_Interp(tkapp),
1043-
value, i, &tcl_elem);
1047+
status = Tcl_ListObjIndex(interp, value, i, &tcl_elem);
10441048
if (status == TCL_ERROR) {
10451049
Py_DECREF(result);
10461050
return Tkinter_Error(tkapp);

0 commit comments

Comments
 (0)