[Python-Dev] f_lineno accessors

Xavier de Gaye xdegaye at gmail.com
Thu Sep 12 22:20:04 CEST 2013


In issues 7238 [1], 16482 [2], 17697 [3] and 17277 [4], the line
number may be incorrect when the global trace function has been
removed but not the frame f_trace function.
A simple test (see below) in issue 17288 [5] crashes the interpreter
when setting f_lineno in a generator from a return trace function.
All those issues are few months old. There is a patch at issue 17277
[4] that fixes the first 4 issues. There is also a patch for issue
17288 [5].


######   Setting f_lineno in a generator   ######
$ cat jump.py
def gen():
     for i in range(1):
         yield i
     lineno = 4

for i in gen():
     pass

$ python -m pdb jump.py
 > /tmp/jump.py(1)<module>()
-> def gen():
(Pdb) import sys; print(sys.version)
3.4.0a1+ (default:975d1e180689, Sep  6 2013, 09:26:12)
[GCC 4.3.2]
(Pdb) break 3
Breakpoint 1 at /tmp/jump.py:3
(Pdb) continue
 > /tmp/jump.py(3)gen()
-> yield i
(Pdb) step
--Return--
 > /tmp/jump.py(3)gen()->0
-> yield i
(Pdb) jump 2
 > /tmp/jump.py(2)gen()->0
-> for i in range(1):
(Pdb) continue
Segmentation fault

[1] http://bugs.python.org/issue7238
[2] http://bugs.python.org/issue16482
[3] http://bugs.python.org/issue17697
[4] http://bugs.python.org/issue17277
[5] http://bugs.python.org/issue17288

Xavier


More information about the Python-Dev mailing list