Ezio Melotti <ezio.melo...@gmail.com> added the comment:

This is an interesting proposal.

The line number comes from Python/traceback.c:120:
    tb->tb_lineno = PyFrame_GetLineNumber(frame);
and this function is defined in Objects/frameobject.c:35:
int PyFrame_GetLineNumber(PyFrameObject *f) {
    if (f->f_trace)
        return f->f_lineno;
    else
        return PyCode_Addr2Line(f->f_code, f->f_lasti);
}
and documented as "Return the line number that frame is currently executing.", 
so that would explain why it's pointing to the last line.

I'm not sure if there's an easy way to get the line where the beginning of the 
expression is, but if you find a way to get it, we could try to use it in 
PyFrame_GetLineNumber and see how it works.

----------
nosy: +ezio.melotti, georg.brandl, ncoghlan
stage:  -> test needed
versions: +Python 3.3 -Python 2.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12458>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to