classification
Title: Support new booleans in Tkinter
Type: enhancement Stage: resolved
Components: Tkinter Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: amaury.forgeotdarc, gpolo, loewis, python-dev, serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2014-05-18 20:41 by serhiy.storchaka, last changed 2015-04-02 22:28 by serhiy.storchaka. This issue is now closed.

Files
File name Uploaded Description Edit
tkinter_newboolean.patch serhiy.storchaka, 2014-05-18 20:41 review
Messages (11)
msg218755 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-05-18 20:41
Recent Tcl versions (since 8.5) no longer use internal "boolean" type. Instead they use "booleanString" type (but looks as only internally). Here is a patch which add support for "booleanString" Tcl type in case when it leaks to user. There are no any new tests because there is no simple way (if any) to create pure Tcl boolean object.
msg238950 - (view) Author: Roundup Robot (python-dev) Date: 2015-03-22 22:48
New changeset e9d86c1de292 by Serhiy Storchaka in branch 'default':
Issue #21526: Tkinter now supports new boolean type in Tcl 8.5.
https://hg.python.org/cpython/rev/e9d86c1de292
msg239750 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2015-03-31 20:49
I'm not sure that this change is correct.
I have Tcl version 8.6 installed, and I checked that "app->BooleanType" is NULL.

Fortunately value->typePtr is probably never NULL, but I think the comparison should be skipped in this case.

Where did you see this booleanString?
msg239751 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-03-31 21:09
The case (value->typePtr == NULL) is tested above for purpose, so it is not a bug when one of type pointers is NULL.

"booleanString" was added in 8.5, replacing "boolean", but in 8.6 it is not used. All boolean values in 8.6 are just integers 0 and 1.
msg239753 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2015-03-31 22:16
Ah, the NULL case is indeed tested just above. So the current code works correctly.
msg239880 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-04-02 07:07
When I said this, I understood that the patch should be backported to maintained releases.

Unpatched Python with Tcl 8.5:

>>> import tkinter; tcl = tkinter.Tcl()
>>> tcl.call('expr', 'false')
<booleanString object: 'false'>
>>> bool(tcl.call('expr', 'false'))
True
msg239886 - (view) Author: Roundup Robot (python-dev) Date: 2015-04-02 08:03
New changeset de3496cd609e by Serhiy Storchaka in branch '3.4':
Issue #21526: Tkinter now supports new boolean type in Tcl 8.5.
https://hg.python.org/cpython/rev/de3496cd609e

New changeset b2413da7516f by Serhiy Storchaka in branch 'default':
Issue #21526: Fixed support of new boolean type in Tcl 8.5.
https://hg.python.org/cpython/rev/b2413da7516f

New changeset d0554559de53 by Serhiy Storchaka in branch '2.7':
Issue #21526: Tkinter now supports new boolean type in Tcl 8.5.
https://hg.python.org/cpython/rev/d0554559de53
msg239889 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-04-02 08:10
And indeed, "app->BooleanType" is NULL, because the "booleanString" type is not registered in Tcl. Thank you for pointing on it Amaury. Now it is fixed.
msg239893 - (view) Author: Roundup Robot (python-dev) Date: 2015-04-02 08:48
New changeset 954e7e1d85f1 by Serhiy Storchaka in branch '2.7':
Issue #21526: Fixed the test_booleans test for wantobjects = 0.
https://hg.python.org/cpython/rev/954e7e1d85f1

New changeset 4255ca2f5314 by Serhiy Storchaka in branch '3.4':
Issue #21526: Fixed the test_booleans test for wantobjects = 0.
https://hg.python.org/cpython/rev/4255ca2f5314

New changeset bb0b5b6c13f3 by Serhiy Storchaka in branch 'default':
Issue #21526: Fixed the test_booleans test for wantobjects = 0.
https://hg.python.org/cpython/rev/bb0b5b6c13f3
msg239916 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-04-02 14:16
http://buildbot.python.org/all/builders/x86%20Tiger%203.x/builds/9465/steps/test/logs/stdio

======================================================================
FAIL: test_booleans (test.test_tcl.TclTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/db3l/buildarea/3.x.bolen-tiger/build/Lib/test/test_tcl.py", line 391, in test_booleans
    check('true', True)
  File "/Users/db3l/buildarea/3.x.bolen-tiger/build/Lib/test/test_tcl.py", line 386, in check
    self.assertEqual(result, expected)
AssertionError: 'true' != True
msg239931 - (view) Author: Roundup Robot (python-dev) Date: 2015-04-02 17:08
New changeset 77e5623e22dd by Serhiy Storchaka in branch '2.7':
Issue #21526: Skip test_booleans on Tcl < 8.5.
https://hg.python.org/cpython/rev/77e5623e22dd

New changeset 3b8039c37b37 by Serhiy Storchaka in branch '3.4':
Issue #21526: Skip test_booleans on Tcl < 8.5.
https://hg.python.org/cpython/rev/3b8039c37b37

New changeset 8ad98ade3f78 by Serhiy Storchaka in branch 'default':
Issue #21526: Skip test_booleans on Tcl < 8.5.
https://hg.python.org/cpython/rev/8ad98ade3f78
History
Date User Action Args
2015-04-02 22:28:46serhiy.storchakasetstatus: open -> closed
resolution: fixed
2015-04-02 17:08:11python-devsetmessages: + msg239931
2015-04-02 14:16:58vstinnersetstatus: closed -> open

nosy: + vstinner
messages: + msg239916

resolution: fixed -> (no value)
2015-04-02 08:48:25python-devsetmessages: + msg239893
2015-04-02 08:10:55serhiy.storchakasetstatus: open -> closed

messages: + msg239889
2015-04-02 08:03:06python-devsetmessages: + msg239886
2015-04-02 07:08:43serhiy.storchakasetstatus: closed -> open
2015-04-02 07:07:19serhiy.storchakasetmessages: + msg239880
2015-03-31 22:16:54amaury.forgeotdarcsetstatus: open -> closed
resolution: fixed
messages: + msg239753
2015-03-31 21:09:06serhiy.storchakasetmessages: + msg239751
2015-03-31 20:49:07amaury.forgeotdarcsetstatus: closed -> open

nosy: + amaury.forgeotdarc
messages: + msg239750

resolution: fixed -> (no value)
2015-03-23 08:34:54serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2015-03-22 22:48:33python-devsetnosy: + python-dev
messages: + msg238950
2014-05-18 20:41:31serhiy.storchakacreate