[Python-checkins] cpython: Issue #21526: Tkinter now supports new boolean type in Tcl 8.5.
serhiy.storchaka
python-checkins at python.org
Sun Mar 22 23:48:31 CET 2015
https://hg.python.org/cpython/rev/e9d86c1de292
changeset: 95138:e9d86c1de292
parent: 95136:f7581ba7fe6f
user: Serhiy Storchaka <storchaka at gmail.com>
date: Mon Mar 23 00:47:45 2015 +0200
summary:
Issue #21526: Tkinter now supports new boolean type in Tcl 8.5.
files:
Misc/NEWS | 2 ++
Modules/_tkinter.c | 20 ++++++++++++--------
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -23,6 +23,8 @@
Library
-------
+- Issue #21526: Tkinter now supports new boolean type in Tcl 8.5.
+
- Issue #23647: Increase impalib's MAXLINE to accommodate modern mailbox sizes.
- Issue #23539: If body is None, http.client.HTTPConnection.request now sets
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -229,6 +229,7 @@
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 @@
}
#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 @@
{
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 @@
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);
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list