呼出し元(ひとつ上のフレーム)の行番号を参照してみるテスト。

import sys

def lineno():
 try:
  raise ValueError
 except:
  return sys.exc_info()[2].tb_frame.f_back.f_lineno