classification
Title: Line numbers reported by extract_stack are offset by the #-*- encoding line
Type: behavior
Components: Library (Lib) Versions: Python 3.0
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ddvoinikov, pitrou
Priority: Keywords:

Created on 2008-05-12 04:52 by ddvoinikov, last changed 2008-07-24 15:26 by pitrou.

Messages
msg66708 (view) Author: Dmitry Dvoinikov (ddvoinikov) Date: 2008-05-12 04:51
Stack trace information extracted with traceback.extract_stack is
incorrect in that the #-*- line causes double counting. For example:

#comment
from traceback import extract_stack
print("this is line", extract_stack()[-1][1])

prints 'this is line 3', but

#comment
#-*- coding: windows-1251 -*-
from traceback import extract_stack
print("this is line", extract_stack()[-1][1])

prints 'this is line 6'
History
Date User Action Args
2008-07-24 15:26:33pitrousetnosy: + pitrou
2008-05-12 04:52:03ddvoinikovcreate