[issue25111] Broken compatibility in FrameSummary equality

Serhiy Storchaka report at bugs.python.org
Mon Sep 14 19:48:43 CEST 2015


New submission from Serhiy Storchaka:

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

----------
components: Library (Lib)
messages: 250693
nosy: rbcollins, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Broken compatibility in FrameSummary equality
type: behavior
versions: Python 3.5, Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25111>
_______________________________________


More information about the Python-bugs-list mailing list