This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2013年12月21日 14:01 by xdegaye, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| tracer.py | xdegaye, 2013年12月21日 14:01 | |||
| f_trace.patch | xdegaye, 2013年12月21日 14:01 | review | ||
| tests.patch | xdegaye, 2013年12月24日 15:15 | review | ||
| none_f_trace.patch | xdegaye, 2016年06月04日 16:32 | review | ||
| Messages (8) | |||
|---|---|---|---|
| msg206735 - (view) | Author: Xavier de Gaye (xdegaye) * (Python triager) | Date: 2013年12月21日 14:01 | |
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.
|
|||
| msg206896 - (view) | Author: Xavier de Gaye (xdegaye) * (Python triager) | Date: 2013年12月24日 15:15 | |
Adding the corresponding tests. |
|||
| msg267094 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年06月03日 12:25 | |
I think the code would be simpler if convert the argument of frame_settrace() to NULL if it is Py_None. |
|||
| msg267157 - (view) | Author: Xavier de Gaye (xdegaye) * (Python triager) | Date: 2016年06月03日 20:15 | |
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 issue 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. |
|||
| msg267158 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年06月03日 20:25 | |
This may be worthwhile optimization, but this is different issue. Let first fix a TypeError, and then open new issue for the optimization. |
|||
| msg267265 - (view) | Author: Xavier de Gaye (xdegaye) * (Python triager) | Date: 2016年06月04日 16:32 | |
This patch fixes the TypeError. New issue 27218: improve tracing performance with f_trace set to Py_None. |
|||
| msg267281 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年06月04日 17:20 | |
LGTM. |
|||
| msg267288 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2016年06月04日 17:42 | |
New changeset 4d916be61d46 by Serhiy Storchaka in branch '2.7': Issue #20041: Fixed TypeError when frame.f_trace is set to None. https://hg.python.org/cpython/rev/4d916be61d46 New changeset 74ad78d2dd8d by Serhiy Storchaka in branch '3.5': Issue #20041: Fixed TypeError when frame.f_trace is set to None. https://hg.python.org/cpython/rev/74ad78d2dd8d New changeset f993dbeb2ad2 by Serhiy Storchaka in branch 'default': Issue #20041: Fixed TypeError when frame.f_trace is set to None. https://hg.python.org/cpython/rev/f993dbeb2ad2 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:55 | admin | set | github: 64240 |
| 2021年08月18日 06:37:50 | rmast | set | nosy:
+ rmast |
| 2016年06月04日 17:42:47 | python-dev | set | nosy:
+ python-dev messages: + msg267288 |
| 2016年06月04日 17:34:11 | serhiy.storchaka | set | status: open -> closed resolution: fixed stage: commit review -> resolved |
| 2016年06月04日 17:20:20 | serhiy.storchaka | set | assignee: serhiy.storchaka stage: patch review -> commit review messages: + msg267281 versions: + Python 3.5, Python 3.6, - Python 3.3, Python 3.4 |
| 2016年06月04日 16:32:57 | xdegaye | set | files:
+ none_f_trace.patch messages: + msg267265 |
| 2016年06月03日 20:25:55 | serhiy.storchaka | set | messages: + msg267158 |
| 2016年06月03日 20:15:45 | xdegaye | set | messages: + msg267157 |
| 2016年06月03日 12:25:17 | serhiy.storchaka | set | messages: + msg267094 |
| 2016年05月18日 21:02:29 | Winterflower | set | nosy:
+ Winterflower |
| 2013年12月24日 15:18:24 | xdegaye | set | components: + Interpreter Core, - 2to3 (2.x to 3.x conversion tool) |
| 2013年12月24日 15:15:16 | xdegaye | set | files:
+ tests.patch messages: + msg206896 components: + 2to3 (2.x to 3.x conversion tool), - Interpreter Core |
| 2013年12月22日 01:10:50 | pitrou | set | nosy:
+ georg.brandl, belopolsky, serhiy.storchaka stage: patch review versions: + Python 3.3 |
| 2013年12月21日 14:01:44 | xdegaye | set | files:
+ f_trace.patch keywords: + patch |
| 2013年12月21日 14:01:27 | xdegaye | create | |