[issue38283] sys._getframe(1).f_lineno changed behavior in 3.8
Thomas Haller
report at bugs.python.org
Thu Sep 26 05:10:54 EDT 2019
New submission from Thomas Haller <thom311 at gmail.com>:
The line number for the frame object changed behaviour in 3.8.
I am seeing this on Fedora rawhide, which ships "3.8.0~b4-1.fc32" package.
That happens when wrapping lines for calling functions.
Before, the line number sys._getframe(1).f_lineno indicate the last line. Now it is the first line.
Reproducer:
>>>
#!/usr/bin/env python
import sys
def func(a, b, c, d):
frame = sys._getframe(1)
print('call: %s' % (a))
print('frame: %s' % (frame))
print('frame.f_code.co_name: %s' % (frame.f_code.co_name))
print('frame.f_lineno: %s' % (frame.f_lineno))
func('call 1, 1 line', 0, 1, 2)
func('call 2, 2 lines',
0, 1, 2)
func('call 3, 4 lines',
0,
1,
2)
<<<<
with python2 and python<=3.7, the line numbers are 16, 19, 24, respectively.
With 3.8, it changes to 16, 18, 21.
----------
messages: 353279
nosy: Thomas Haller
priority: normal
severity: normal
status: open
title: sys._getframe(1).f_lineno changed behavior in 3.8
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38283>
_______________________________________
More information about the Python-bugs-list
mailing list