Bug 1315228 - traceback.extract_tb() returns a list of FrameSummary instead of a list of tuples
Summary: traceback.extract_tb() returns a list of FrameSummary instead of a list of tu...
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: python3
Version: 25
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Charalampos Stratakis
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-03-07 09:59 UTC by Jakub Filak
Modified: 2017-08-07 11:44 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-08-07 11:44:49 UTC
Type: Bug


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Python 26502 0 None None None 2016-08-30 10:01:18 UTC
Python 27910 0 None None None 2016-08-31 11:25:16 UTC

Description Jakub Filak 2016-03-07 09:59:52 UTC
Description of problem:
The documentation says that traceback.extract_bt() returns a list of tuples[1] but a list of FrameSymbols is returned instead. This is an unexpected API change that caused ABRT Python3 addon to stop working.

Version-Release number of selected component (if applicable):
python3-3.5.1-4.fc24.x86_64

How reproducible:
always

Steps to Reproduce:
import sys
import traceback

try:
    tuple()[0]
except IndexError:
    _, _, exc_traceback = sys.exc_info()
    tb = traceback.extract_tb(exc_traceback, limit=None)
    print(str(tb[0]))


Actual results:
<FrameSummary file tb.py, line 5 in <module>>

Expected results:
('tb.py', 5, '<module>', 'tuple()[0]')



1: https://docs.python.org/3/library/traceback.html#traceback.extract_tb

Comment 1 Petr Viktorin 2016-03-07 11:20:06 UTC
Indeed, this is a compatibility break and a documentation bug. Filed upstream: http://bugs.python.org/issue26502

I don't think this will be fixed fast enough for you, so I suggest that ABRT works around the issue by converting to tuple. (This is a no-op in 3.4 and earlier. In 3.5+ it will do the work of looking up the corresponding line in the source file, since FrameSummary is lazy.)
Sorry for the inconvenience!

In abrt_exception_handler3.py, it should be enough to replace

    if len(tblast):
        tblast = tblast[len(tblast) - 1]

by

    if tblast:
        tblast = tuple(tblast[-1])

Comment 2 Jan Kurik 2016-07-26 04:10:24 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 25 development cycle.
Changing version to '25'.


Note You need to log in before you can comment on or make changes to this bug.