Skip to content

Broken compatibility in FrameSummary equality #69298

Closed

Description

@serhiy-storchaka
BPO 25111
Nosy @vstinner, @rbtcollins, @berkerpeksag, @serhiy-storchaka
Files
  • traceback_FrameSummary_equality.patch
  • traceback_FrameSummary_equality_2.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-09-29.19:37:09.222>
    created_at = <Date 2015-09-14.17:48:43.752>
    labels = ['type-bug', 'library']
    title = 'Broken compatibility in FrameSummary equality'
    updated_at = <Date 2015-09-29.19:37:09.221>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2015-09-29.19:37:09.221>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2015-09-29.19:37:09.222>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2015-09-14.17:48:43.752>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['40463', '40500']
    hgrepos = []
    issue_num = 25111
    keywords = ['patch']
    message_count = 7.0
    messages = ['250693', '250953', '251722', '251760', '251834', '251835', '251880']
    nosy_count = 5.0
    nosy_names = ['vstinner', 'rbcollins', 'python-dev', 'berker.peksag', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue25111'
    versions = ['Python 3.5', 'Python 3.6']

    Activity

    1. serhiy-storchaka commented on Sep 14, 2015

      @serhiy-storchaka
      MemberAuthor

      Since 3.5 traceback.extract_tb() and traceback.extract_stack() return a list (actually list's subclass StackSummary) of FrameSummary objects instead of a list of tuples. FrameSummary is not fully compatible with tuple. One important incompatibility is in the comparing.

      >>> import traceback
      >>> traceback.extract_stack()[0] == ('<stdin>', 1, '<module>', '')
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "/home/serhiy/py/cpython-3.5/Lib/traceback.py", line 254, in __eq__
          return (self.filename == other.filename and
      AttributeError: 'tuple' object has no attribute 'filename'

      In general __eq__ shouldn't raise an exception. bpo-25108 is needed to be fixed first for tests.

      Here is a patch that restores compatibility.

      An alternative solution would be to make FrameSummary a subclass of tuple (namedtuple).

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on Sep 14, 2015
    3. serhiy-storchaka commented on Sep 18, 2015

      @serhiy-storchaka
      MemberAuthor

      Fixed patch and added tests.

    4. serhiy-storchaka commented on Sep 27, 2015

      @serhiy-storchaka
      MemberAuthor

      Ping.

    5. berkerpeksag commented on Sep 28, 2015

      @berkerpeksag
      Member

      LGTM

      + self.assertEqual(f, tuple(f))
      + self.assertEqual(tuple(f), f)

      It would be good to add a comment to explain why we test both variants, but it's not really important.

    6. vstinner commented on Sep 29, 2015

      @vstinner
      Member

      traceback_FrameSummary_equality_2.patch looks good to me, but I have the same remark than Berker (see the review).

    7. rbtcollins commented on Sep 29, 2015

      @rbtcollins
      Member

      LGTM too.

    8. python-dev commented on Sep 29, 2015

      python-devmannequin
      Mannequin

      New changeset 2ecb7d4d9e0b by Serhiy Storchaka in branch '3.5':
      Issue bpo-25111: Fixed comparison of traceback.FrameSummary.
      https://hg.python.org/cpython/rev/2ecb7d4d9e0b

      New changeset f043182a81d7 by Serhiy Storchaka in branch 'default':
      Issue bpo-25111: Fixed comparison of traceback.FrameSummary.
      https://hg.python.org/cpython/rev/f043182a81d7

    9. 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

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions