Bug 1315228

Summary: traceback.extract_tb() returns a list of FrameSummary instead of a list of tuples
Product: [Fedora] Fedora Reporter: Jakub Filak <jfilak>
Component: python3Assignee: Charalampos Stratakis <cstratak>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 25CC: bkabrda, cstratak, jberan, mstuchli, pviktori, tomspur, torsava
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-07 11:44:49 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

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