diff Python/traceback.c @ 53931:9ef683d41c9b legacy-trunk

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.
author Jeffrey Yasskin <jyasskin@gmail.com>
date Fri, 08 May 2009 22:23:21 +0000
parents fb80b281e05a
children 5dec8a12e455
line wrap: on
line diff
--- a/Python/traceback.c	Fri May 08 21:51:06 2009 +0000
+++ b/Python/traceback.c	Fri May 08 22:23:21 2009 +0000
@@ -96,8 +96,7 @@
 		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;