Navigation Menu

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

ttk.Treeview.insert() does not allow to insert item with "False" iid #77277

Closed
igoryakovchenko mannequin opened this issue Mar 18, 2018 · 10 comments
Closed

ttk.Treeview.insert() does not allow to insert item with "False" iid #77277

igoryakovchenko mannequin opened this issue Mar 18, 2018 · 10 comments
Assignees
Labels
3.7 (EOL) end of life 3.8 only security fixes easy topic-tkinter type-bug An unexpected behavior, bug, or error

Comments

@igoryakovchenko
Copy link
Mannequin

igoryakovchenko mannequin commented Mar 18, 2018

BPO 33096
Nosy @terryjreedy, @serhiy-storchaka, @garvitdelhi, @miss-islington
PRs
  • bpo-33096 Modify ttk.Treeview.insert #6228
  • [3.7] bpo-33096: Fix ttk.Treeview.insert. (GH-6228) #6246
  • [3.6] bpo-33096: Fix ttk.Treeview.insert. (GH-6228) #6247
  • [2.7] bpo-33096: Fix ttk.Treeview.insert. (GH-6228) #6326
  • bpo-33096: Removed unintentionally backported from Python 3 Tkinter files. #6724
  • 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 2018-04-01.07:43:55.567>
    created_at = <Date 2018-03-18.09:09:10.864>
    labels = ['3.7', '3.8', 'type-bug', 'expert-tkinter', 'easy']
    title = 'ttk.Treeview.insert() does not allow to insert item with "False" iid'
    updated_at = <Date 2018-05-08.07:09:11.502>
    user = 'https://bugs.python.org/igoryakovchenko'

    bugs.python.org fields:

    activity = <Date 2018-05-08.07:09:11.502>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2018-04-01.07:43:55.567>
    closer = 'serhiy.storchaka'
    components = ['Tkinter']
    creation = <Date 2018-03-18.09:09:10.864>
    creator = 'igor.yakovchenko'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 33096
    keywords = ['patch', 'easy']
    message_count = 10.0
    messages = ['314032', '314338', '314356', '314381', '314383', '314439', '314440', '314441', '314751', '316280']
    nosy_count = 6.0
    nosy_names = ['terry.reedy', 'gpolo', 'serhiy.storchaka', 'garvitdelhi', 'miss-islington', 'igor.yakovchenko']
    pr_nums = ['6228', '6246', '6247', '6326', '6724']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue33096'
    versions = ['Python 2.7', 'Python 3.6', 'Python 3.7', 'Python 3.8']

    @igoryakovchenko
    Copy link
    Mannequin Author

    igoryakovchenko mannequin commented Mar 18, 2018

    ttk.Treeview.insert(... iid=None, ...) method has a check:
    if iid:
    res = self.tk.call(self._w, "insert", parent, index,
    "-id", iid, *opts)
    else:
    res = self.tk.call(self._w, "insert", parent, index, *opts)

    Documentation says that "If iid is specified, it is used as the item identifier", but as you can see from code, iid is used only if it's "True". It means that you cannot use iids like 0, 0.0 etc.

    @igoryakovchenko igoryakovchenko mannequin added topic-tkinter type-bug An unexpected behavior, bug, or error labels Mar 18, 2018
    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life 3.8 only security fixes labels Mar 18, 2018
    @serhiy-storchaka serhiy-storchaka self-assigned this Mar 18, 2018
    @terryjreedy
    Copy link
    Member

    This was initially reported in pydev thread "ttk.Treeview.insert() does not allow to insert item with iid=0" on 2018/3/16. Igor, you should have mentioned on the thread that you had opened a tracker issue in response. It was only happenstance that I did not open a duplicate.

    I suggested there that 'if iid:' be replaced by 'if iid is not None:' but wondered if passing '"-id" ""' in the tk.call would be a problem. If so, that would be a reason for the expanded check and suggest 'if iid in (None, ''):" as the replacement.

    MRAB responded that '' is the id of the root of the tree. But that does not tell me if passing a duplicate iid or that particular duplicate is a problem or not.

    @serhiy-storchaka
    Copy link
    Member

    I have tested -- omitting the option and passing an empty string are treated different in Tk. Passing a duplicate iid is error. Thus the fix should be just iid is not None. But needed tests.

    @garvitdelhi
    Copy link
    Mannequin

    garvitdelhi mannequin commented Mar 24, 2018

    I made the changes on my machine and I\in my testing, it breaks on an empty string with an error saying
    "Item already exists". If this is expected I would like to submit a patch with tests for the same.

    @serhiy-storchaka
    Copy link
    Member

    Yes, this is expected.

    @serhiy-storchaka
    Copy link
    Member

    New changeset 3ab44c0 by Serhiy Storchaka (Garvit Khatri) in branch 'master':
    bpo-33096: Fix ttk.Treeview.insert. (GH-6228)
    3ab44c0

    @miss-islington
    Copy link
    Contributor

    New changeset a7b1b84 by Miss Islington (bot) in branch '3.7':
    bpo-33096: Fix ttk.Treeview.insert. (GH-6228)
    a7b1b84

    @miss-islington
    Copy link
    Contributor

    New changeset 45116d3 by Miss Islington (bot) in branch '3.6':
    bpo-33096: Fix ttk.Treeview.insert. (GH-6228)
    45116d3

    @serhiy-storchaka
    Copy link
    Member

    New changeset e80a232 by Serhiy Storchaka in branch '2.7':
    [2.7] bpo-33096: Fix ttk.Treeview.insert. (GH-6228) (GH-6326)
    e80a232

    @serhiy-storchaka
    Copy link
    Member

    New changeset 903f189 by Serhiy Storchaka in branch '2.7':
    bpo-33096: Removed unintentionally backported from Python 3 Tkinter files. (GH-6724)
    903f189

    @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.7 (EOL) end of life 3.8 only security fixes easy topic-tkinter type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants