Runtime Data Attributes

traceback.tb_lineno

Source line recorded for the exception event. It may differ from the associated frame's current line, for example after finally cleanup.

Formal Syntax & Structure

python syntaxpython
tb.tb_lineno

Return Value

int

Value exposed by this attribute; availability and mutability depend on the owner as described.

Working Example

Example Snippetpython
ns = {}exec(compile('def fail():\n    raise ValueError("demo")','<demo>','exec'),ns)try: ns['fail']()except ValueError as e: tb = e.__traceback__.tb_nextprint(tb.tb_lineno)
Python Reference