Bugs item #1251026, was opened at 2005-08-03 12:54 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1251026&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Rob W.W. Hooft (hooft) Assigned to: Nobody/Anonymous (nobody) Summary: cgitb gives wrong lineno inside try:..finally: Initial Comment: If an error occurs in a try: finally: block, the normal traceback prints the correct line number, but the cgitb module prints the error as if it occurred in the last line of the finally: block. Example code: ==================== import cgitb cgitb.enable() try: 0//0 finally: print "This is not where the exception occurred!" ===================== Traceback correctly reports the error in line 5, but cgitb reports line 7. I am using python-2.3.4 on Debian/Linux. Probable cause: the inspect module, in getframeinfo, uses the f_lineno attribute from the frame object. This is what is printed in the cgitb trace. The traceback module uses the tb_lineno object of the traceback object itself, which is correct. Workaround: I am now working around this by using tb.tb_lineno in inspect.getframeinfo if a traceback object was passed, and f.f_lineno if a frame object was passed. I do not have sufficient insight in the code to foresee any other problems with this fix. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1251026&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com