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

Tkinter: deprecate the split() method #82552

Closed
serhiy-storchaka opened this issue Oct 4, 2019 · 4 comments
Closed

Tkinter: deprecate the split() method #82552

serhiy-storchaka opened this issue Oct 4, 2019 · 4 comments
Labels
3.9 only security fixes topic-tkinter

Comments

@serhiy-storchaka
Copy link
Member

BPO 38371
Nosy @zware, @serhiy-storchaka, @erlend-aasland
PRs
  • bpo-38371: Tkinter: deprecate the split() method. #16584
  • bpo-38371: Remove deprecated tkinter split() method #28237
  • bpo-38371: Remove remaining use of tk.split from bigmem tcl test #29082
  • 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 = None
    closed_at = <Date 2019-10-08.11:37:58.853>
    created_at = <Date 2019-10-04.15:33:41.699>
    labels = ['expert-tkinter', '3.9']
    title = 'Tkinter: deprecate the split() method'
    updated_at = <Date 2021-10-20.03:34:31.551>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2021-10-20.03:34:31.551>
    actor = 'zach.ware'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-10-08.11:37:58.853>
    closer = 'serhiy.storchaka'
    components = ['Tkinter']
    creation = <Date 2019-10-04.15:33:41.699>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38371
    keywords = ['patch']
    message_count = 4.0
    messages = ['353948', '354186', '401422', '404391']
    nosy_count = 3.0
    nosy_names = ['zach.ware', 'serhiy.storchaka', 'erlendaasland']
    pr_nums = ['16584', '28237', '29082']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue38371'
    versions = ['Python 3.9']

    @serhiy-storchaka
    Copy link
    Member Author

    The tkapp.split() method has weird behavior. It splits a string recursively, so the type of items and the depth of nesting depends on spaces in string values. For example:

    >>> import tkinter
    >>> root = tkinter.Tcl()
    >>> root.tk.split('Hi')
    'Hi'
    >>> root.tk.split('Hello "Good bye"')
    ('Hello', ('Good', 'bye'))

    It may work as you meant in some cases (if items at the same level either all have spaces or all do not have spaces), but return unexpected result for untested cases. It is more robust to use the tkapp.splitlist() method, which split exactly one level and always returns a tuple of strings. It can be used recursively if you need nested lists.

    >>> root.tk.splitlist('Hi')
    ('Hi',)
    >>> root.tk.splitlist('Hello "Good bye"')
    ('Hello', 'Good bye')
    >>> [root.tk.splitlist(x) for x in root.tk.splitlist('Hello "Good bye"')]
    [('Hello',), ('Good', 'bye')]

    @serhiy-storchaka serhiy-storchaka added 3.9 only security fixes topic-tkinter labels Oct 4, 2019
    @serhiy-storchaka
    Copy link
    Member Author

    New changeset d05b000 by Serhiy Storchaka in branch 'master':
    bpo-38371: Tkinter: deprecate the split() method. (GH-16584)
    d05b000

    @serhiy-storchaka
    Copy link
    Member Author

    New changeset f235dd0 by Erlend Egeberg Aasland in branch 'main':
    bpo-38371: Remove deprecated tkinter split() method (GH-28237)
    f235dd0

    @zware
    Copy link
    Member

    zware commented Oct 20, 2021

    New changeset 085ccb0 by Zachary Ware in branch 'main':
    bpo-38371: Remove remaining use of tk.split from bigmem tcl test (GH-29082)
    085ccb0

    @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
    3.9 only security fixes topic-tkinter
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants