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

Broken compatibility in FrameSummary equality #69298

Closed
serhiy-storchaka opened this issue Sep 14, 2015 · 7 comments
Closed

Broken compatibility in FrameSummary equality #69298

serhiy-storchaka opened this issue Sep 14, 2015 · 7 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

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']

    @serhiy-storchaka
    Copy link
    Member Author

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

    @serhiy-storchaka serhiy-storchaka added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Sep 14, 2015
    @serhiy-storchaka
    Copy link
    Member Author

    Fixed patch and added tests.

    @serhiy-storchaka
    Copy link
    Member Author

    Ping.

    @berkerpeksag
    Copy link
    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.

    @vstinner
    Copy link
    Member

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

    @rbtcollins
    Copy link
    Member

    LGTM too.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Sep 29, 2015

    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

    @serhiy-storchaka serhiy-storchaka self-assigned this Sep 29, 2015
    @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
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants