New submission from Mark Shannon <m...@hotpy.org>:

The logic for frame.f_lineno assumes that the internal C field will be updated 
when f_trace is set, but that is incorrect.
Consequently, the following code

import sys

def print_line():
    print(sys._getframe(1).f_lineno)

def test():
    print_line()
    sys._getframe(0).f_trace = True
    print_line()
    print_line()

test()

prints
7
8
8

it should print
7
9
10


Fixing this is required by PEP 626, but it should be fixed anyway.

----------
assignee: Mark.Shannon
messages: 384331
nosy: Mark.Shannon
priority: normal
severity: normal
status: open
title: Incorrect frame.f_lineno when frame.f_trace is set

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42823>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to