I have a code similar to this:
try: if x: statement1 statement2 statement3 elif y: statement4 statement5 statement6
You should wrap the statements you care about more tightly. Extracting the line number from the traceback is going to be involved and fragile.