-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
TypeError when f_trace is None and tracing. #64240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Section 3.2 of 'The Python Language Reference' states: 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 The attached patch fixes this issue. |
Adding the corresponding tests. |
I think the code would be simpler if convert the argument of frame_settrace() to NULL if it is Py_None. |
On a 'call' trace event, the bdb dispatch_call() function returns None when there is nothing to trace in this function (no breakpoints). With the changes made by the patch in ceval.c, the costly maybe_call_line_trace() function is not called on each line in this case since f->f_trace is Py_None. This provides the performance enhancements described in bpo-16672 without breaking the _hotshot extension module or other extension modules using PyEval_SetTrace(). I agree that the code would be much simpler when f->f_trace is set to NULL by the frame_settrace() setter or trace_trampoline() when it is Py_None. The performance gain described above by using Py_None may not be worth the complexity. Thanks for looking into this Serhiy. |
This may be worthwhile optimization, but this is different issue. Let first fix a TypeError, and then open new issue for the optimization. |
This patch fixes the TypeError. |
LGTM. |
New changeset 4d916be61d46 by Serhiy Storchaka in branch '2.7': New changeset 74ad78d2dd8d by Serhiy Storchaka in branch '3.5': New changeset f993dbeb2ad2 by Serhiy Storchaka in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: