New submission from Xavier de Gaye:

Section 3.2 of 'The Python Language Reference' states:
  f_trace, if not None, is a function called at the start of each source code 
line

Run the attached tracer.py and see that although f_trace is None in both cases 
when 'cmd' is either
'delete' or 'set', the second case raises a TypeError exception:
$ python tracer.py
f_trace: None
delete start
delete done
f_trace: None
set start
Traceback (most recent call last):
  File "tracer.py", line 19, in <module>
    foo('set')
  File "tracer.py", line 15, in foo
    print(cmd, 'done')
  File "tracer.py", line 15, in foo
    print(cmd, 'done')
TypeError: 'NoneType' object is not callable

Also, the frame.f_lineno may be wrong in a traceback when f_trace is set to 
None because
PyFrame_GetLineNumber() does not handle this case.

The attached patch fixes this issue.
The patch also fixes issue 11992 and issue 20040.
The patch also fixes the dispatch_call() method of Bdb in the bdb module when 
the frame is a
generator and the previous command is next, until or return.
The patch also provides a backward compatible solution to the performance 
enhancement described in
issue 16672.

----------
components: Interpreter Core
files: tracer.py
messages: 206735
nosy: xdegaye
priority: normal
severity: normal
status: open
title: TypeError when f_trace is None and tracing.
type: behavior
versions: Python 3.4
Added file: http://bugs.python.org/file33245/tracer.py

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

Reply via email to