I was debugging my python script and came across traceback
object, which is present at 2nd index in result, returned by sys.exc_info()
function. However, I tried to google out information related to traceback
object, but everywhere i got link to traceback module
in standard python lib. Then, I tried doing dir()
on traceback object, which gives me a list of attributes. In that list, following attributes looks interesting :-
1. tb_frame,
2. tb_lasti,
3. tb_lineno,
4. tb_next
I know about tb_frame and tb_lineno, but what rest of other attributes indicates ?
Apologizing for bad English. Thanks in advance.
As specified by in docpage specified by @vaultah,
These all are special read-only attributes.
tb_next
is the next level in the stack trace (towards the frame where the exception occurred), or None if there is no next level;tb_frame
points to the execution frame of the current level;tb_lineno
gives the line number where the exception occurred;tb_lasti
indicates the precise instruction.Note :- The line number and last instruction in the traceback may differ from the line number of its frame object if the exception occurred in a try statement with no matching except clause or with a finally clause.