mirror of
https://github.com/python/cpython.git
synced 2025-08-01 15:43:13 +00:00
Issue 5954, PyFrame_GetLineNumber:
Most uses of PyCode_Addr2Line (http://www.google.com/codesearch?q=PyCode_Addr2Line) are just trying to get the line number of a specified frame, but there's no way to do that directly. Forcing people to go through the code object makes them know more about the guts of the interpreter than they should need. The remaining uses of PyCode_Addr2Line seem to be getting the line from a traceback (for example, http://www.google.com/codesearch/p?hl=en#u_9_nDrchrw/pygame-1.7.1release/src/base.c&q=PyCode_Addr2Line), which is replaced by the tb_lineno field. So we may be able to deprecate PyCode_Addr2Line entirely for external use.
This commit is contained in:
parent
1aa4700234
commit
f7f858d141
8 changed files with 36 additions and 20 deletions
|
@ -454,7 +454,7 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
|
|||
}
|
||||
else {
|
||||
globals = f->f_globals;
|
||||
*lineno = PyCode_Addr2Line(f->f_code, f->f_lasti);
|
||||
*lineno = PyFrame_GetLineNumber(f);
|
||||
}
|
||||
|
||||
*module = NULL;
|
||||
|
|
|
@ -2698,7 +2698,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
|
|||
default:
|
||||
fprintf(stderr,
|
||||
"XXX lineno: %d, opcode: %d\n",
|
||||
PyCode_Addr2Line(f->f_code, f->f_lasti),
|
||||
PyFrame_GetLineNumber(f),
|
||||
opcode);
|
||||
PyErr_SetString(PyExc_SystemError, "unknown opcode");
|
||||
why = WHY_EXCEPTION;
|
||||
|
|
|
@ -96,8 +96,7 @@ newtracebackobject(PyTracebackObject *next, PyFrameObject *frame)
|
|||
Py_XINCREF(frame);
|
||||
tb->tb_frame = frame;
|
||||
tb->tb_lasti = frame->f_lasti;
|
||||
tb->tb_lineno = PyCode_Addr2Line(frame->f_code,
|
||||
frame->f_lasti);
|
||||
tb->tb_lineno = PyFrame_GetLineNumber(frame);
|
||||
PyObject_GC_Track(tb);
|
||||
}
|
||||
return tb;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue