Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support new booleans in Tkinter #65725

Closed
serhiy-storchaka opened this issue May 18, 2014 · 11 comments
Closed

Support new booleans in Tkinter #65725

serhiy-storchaka opened this issue May 18, 2014 · 11 comments
Assignees
Labels
topic-tkinter type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

BPO 21526
Nosy @loewis, @amauryfa, @vstinner, @serhiy-storchaka
Files
  • tkinter_newboolean.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2015-04-02.22:28:46.688>
    created_at = <Date 2014-05-18.20:41:31.789>
    labels = ['type-feature', 'expert-tkinter']
    title = 'Support new booleans in Tkinter'
    updated_at = <Date 2015-04-02.22:28:46.687>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2015-04-02.22:28:46.687>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2015-04-02.22:28:46.688>
    closer = 'serhiy.storchaka'
    components = ['Tkinter']
    creation = <Date 2014-05-18.20:41:31.789>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['35284']
    hgrepos = []
    issue_num = 21526
    keywords = ['patch']
    message_count = 11.0
    messages = ['218755', '238950', '239750', '239751', '239753', '239880', '239886', '239889', '239893', '239916', '239931']
    nosy_count = 6.0
    nosy_names = ['loewis', 'amaury.forgeotdarc', 'vstinner', 'gpolo', 'python-dev', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue21526'
    versions = ['Python 3.5']

    @serhiy-storchaka
    Copy link
    Member Author

    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.

    @serhiy-storchaka serhiy-storchaka self-assigned this May 18, 2014
    @serhiy-storchaka serhiy-storchaka added topic-tkinter type-feature A feature request or enhancement labels May 18, 2014
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 22, 2015

    New changeset e9d86c1de292 by Serhiy Storchaka in branch 'default':
    Issue bpo-21526: Tkinter now supports new boolean type in Tcl 8.5.
    https://hg.python.org/cpython/rev/e9d86c1de292

    @amauryfa
    Copy link
    Member

    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?

    @amauryfa amauryfa reopened this Mar 31, 2015
    @serhiy-storchaka
    Copy link
    Member Author

    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.

    @amauryfa
    Copy link
    Member

    Ah, the NULL case is indeed tested just above. So the current code works correctly.

    @serhiy-storchaka
    Copy link
    Member Author

    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

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 2, 2015

    New changeset de3496cd609e by Serhiy Storchaka in branch '3.4':
    Issue bpo-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 bpo-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 bpo-21526: Tkinter now supports new boolean type in Tcl 8.5.
    https://hg.python.org/cpython/rev/d0554559de53

    @serhiy-storchaka
    Copy link
    Member Author

    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.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 2, 2015

    New changeset 954e7e1d85f1 by Serhiy Storchaka in branch '2.7':
    Issue bpo-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 bpo-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 bpo-21526: Fixed the test_booleans test for wantobjects = 0.
    https://hg.python.org/cpython/rev/bb0b5b6c13f3

    @vstinner
    Copy link
    Member

    vstinner commented Apr 2, 2015

    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

    @vstinner vstinner reopened this Apr 2, 2015
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 2, 2015

    New changeset 77e5623e22dd by Serhiy Storchaka in branch '2.7':
    Issue bpo-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 bpo-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 bpo-21526: Skip test_booleans on Tcl < 8.5.
    https://hg.python.org/cpython/rev/8ad98ade3f78

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    topic-tkinter type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants