Bug 716435 - Tracebacks should contain the first line of continuation lines
Tracebacks should contain the first line of continuation lines
Status: CLOSED WONTFIX
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: python (Show other bugs)
6.1
Unspecified Unspecified
medium Severity medium
: rc
: ---
Assigned To: Dave Malcolm
BaseOS QE - Apps
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2011-06-24 08:30 EDT by Petr Šplíchal
Modified: 2016-05-31 21:42 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-06-30 20:15:04 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Petr Šplíchal 2011-06-24 08:30:32 EDT
Description of problem:

Currently, python tracebacks shows the last of continuation lines
when a function spans across multiple lines. This line usually
contains some function parameter only and thus is not very useful
for debugging the problem.

For example:

    Traceback (most recent call last):
    File "./tcms-run", line 48, in <module>
        summary=options.summary)
    File "/home/psss/git/tcms/Nitrate.py", line 600, in __init__
        raise NitrateError("Need either id or test plan")

If the traceback contained the beginning of the continuation line
it would be IMHO much more clear where/how the problem happened.

    Traceback (most recent call last):
    File "./tcms-run", line 48, in <module>
        run = TestRun(plan=plan, distro=options.distro,
    File "/home/psss/git/tcms/Nitrate.py", line 600, in __init__
        raise NitrateError("Need either id or test plan")

Version-Release number of selected component (if applicable):
python-2.6.6-20.el6.x86_64

Trivial reproducer:

    def fun1(par):
        raise Exception
    def fun2():
        fun1(
                par="value")
    fun2()

Actual results:

    Traceback (most recent call last):
    File "/tmp/traceback.py", line 10, in <module>
        fun2()
    File "/tmp/traceback.py", line 8, in fun2
        par="value")
    File "/tmp/traceback.py", line 4, in fun1
        raise Exception
    Exception
Comment 1 Dave Malcolm 2011-06-30 20:11:33 EDT
The printing code in question is within Python/traceback.c
It uses the tb->tb_lineno of a PyTracebackObject to determine which line to print, and tb_lineno is in fact exposed to Python code; see:
  http://docs.python.org/library/traceback.html

It's set up in newtracebackobject (called by PyTraceBack_Here(PyFrameObject *frame)) based on the last bytecode being executed within the frame:

     PyCode_Addr2Line(frame->f_code,
                      frame->f_lasti)
Comment 3 RHEL Product and Program Management 2011-06-30 20:15:04 EDT
Development Management has reviewed and declined this request.  You may appeal
this decision by reopening this request.
Comment 4 Petr Šplíchal 2011-07-01 01:49:18 EDT
OK, filed upstream as: http://bugs.python.org/issue12458

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