Skip to content

ValueError using index on tuple is not showing the tuple value #83680

Closed

Description

@tuxskar
mannequin
BPO 39499
Nosy @tirkarthi, @tuxskar
Superseder
  • bpo-13349: Non-informative error message in index() and remove() functions
  • 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 2020-01-30.09:03:41.752>
    created_at = <Date 2020-01-30.07:41:48.457>
    labels = ['type-bug', '3.8']
    title = 'ValueError using index on tuple is not showing the tuple value'
    updated_at = <Date 2020-01-30.09:03:41.749>
    user = 'https://github.com/tuxskar'

    bugs.python.org fields:

    activity = <Date 2020-01-30.09:03:41.749>
    actor = 'xtreak'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-01-30.09:03:41.752>
    closer = 'xtreak'
    components = []
    creation = <Date 2020-01-30.07:41:48.457>
    creator = 'tuxskar'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 39499
    keywords = []
    message_count = 2.0
    messages = ['361016', '361025']
    nosy_count = 2.0
    nosy_names = ['xtreak', 'tuxskar']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '13349'
    type = 'behavior'
    url = 'https://bugs.python.org/issue39499'
    versions = ['Python 3.8']

    Activity

    1. tuxskar commented on Jan 30, 2020

      tuxskarmannequin
      MannequinAuthor

      When trying to retrieve the index of an element that is not in a tuple the error message of ValueError is not showing the value looking for but instead a static message tuple.index(x): x not in tuple

      >>> b = (1, 2, 3, 4)
      >>> b.index(5)
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      ValueError: tuple.index(x): x not in tuple
      
      I would expect something like what happen in lists where the element (5 in this case) is showed on the ValueError.
      >>> a = [1, 2, 3, 4]
      >>> a.index(5)
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      ValueError: 5 is not in list
    2. tirkarthi commented on Jan 30, 2020

      @tirkarthi
      Member

      This is a duplicate of bpo-33560. See also bpo-13349 which is the original duplicate.

    3. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.8 (EOL)end of lifetype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions