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.

classification
Title: settrace docs are wrong about "c_call" events
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.7, Python 3.6, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, gvanrossum, ionelmc, nedbat, raylu, xiang.zhang
Priority: low Keywords: patch

Created on 2013-04-20 03:36 by nedbat, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4056 merged pablogsal, 2017-10-20 09:04
PR 5298 merged xiang.zhang, 2018-01-24 13:43
PR 5299 merged xiang.zhang, 2018-01-24 13:58
Messages (9)
msg187406 - (view) Author: Ned Batchelder (nedbat) * (Python triager) Date: 2013-04-20 03:36
Looking into this Stack Overflow question:  http://stackoverflow.com/questions/16115027/pythons-sys-settrace-wont-create-c-call-events

Reading the code in c_eval.c and friends, it looks like "c_call" events are never passed to the trace function, only to the profile function.  The docs are wrong and should be fixed.

The setprofile docs simply point to settrace for details, so the text needs to accommodate both functions' needs.
msg228143 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-10-02 00:21
@Ned can you provide a patch for this?
msg309797 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2018-01-11 09:10
Is there any reason not to respond to "c_call" events in trace function?
msg310383 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2018-01-21 21:01
The reason not to pass C calls to the tracing function is that tracing exists to support pdb and other debuggers, and pdb only cares about tracing through Python code. So the docs should be updated.
msg310393 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2018-01-22 03:06
Hi Guido. Looking at the implementation, it seems pdb ignores c_call not by relying on the interpreter, but bdb takes no action when encountering C events. Yeah, even bdb wrongly expects C events will be triggered for settrace. [1]

And what if some debuggers want not only to trace Python events but also C events, then it has to mix the power of trace and profile but can't only rely on trace.

[1] https://github.com/python/cpython/blob/master/Lib/bdb.py#L59
msg310396 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2018-01-22 06:03
Too bad, it's been like this since the feature was first created. It would
most likely break other code that uses the tracing hooks, so you'd have to
propose it as a new feature.
msg310587 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2018-01-24 12:57
New changeset 131fd7f96c619bc7eaea956e45c6337175f4b27f by Xiang Zhang (Pablo Galindo) in branch 'master':
bpo-17799: Explain real behaviour of sys.settrace and sys.setprofile (#4056)
https://github.com/python/cpython/commit/131fd7f96c619bc7eaea956e45c6337175f4b27f
msg310598 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2018-01-24 14:44
New changeset fd844efa9c31e1f00e04b07940875b9dacff3d77 by Xiang Zhang in branch '3.6':
bpo-17799: Explain real behaviour of sys.settrace and sys.setprofile (GH-4056) (#5298)
https://github.com/python/cpython/commit/fd844efa9c31e1f00e04b07940875b9dacff3d77
msg310599 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2018-01-24 14:53
New changeset e64a47b37d0c592fd162b2f51e79ecfd046b45ec by Xiang Zhang in branch '2.7':
bpo-17799: Explain real behaviour of sys.settrace and sys.setprofile (GH-4056). (#5299)
https://github.com/python/cpython/commit/e64a47b37d0c592fd162b2f51e79ecfd046b45ec
History
Date User Action Args
2022-04-11 14:57:44adminsetgithub: 61999
2018-01-24 14:54:45xiang.zhangsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-01-24 14:53:44xiang.zhangsetmessages: + msg310599
2018-01-24 14:44:55xiang.zhangsetmessages: + msg310598
2018-01-24 13:58:11xiang.zhangsetpull_requests: + pull_request5146
2018-01-24 13:43:01xiang.zhangsetpull_requests: + pull_request5145
2018-01-24 12:57:52xiang.zhangsetmessages: + msg310587
2018-01-22 06:03:10gvanrossumsetmessages: + msg310396
2018-01-22 03:06:04xiang.zhangsetmessages: + msg310393
versions: + Python 3.6, Python 3.7, - Python 3.4, Python 3.5
2018-01-21 21:01:31gvanrossumsetnosy: + gvanrossum
messages: + msg310383
2018-01-11 09:12:45BreamoreBoysetnosy: - BreamoreBoy
2018-01-11 09:10:45xiang.zhangsetnosy: + xiang.zhang
messages: + msg309797
2017-10-20 09:04:12pablogsalsetkeywords: + patch
stage: patch review
pull_requests: + pull_request4025
2017-10-19 09:27:26raylusetnosy: + raylu
2015-03-18 21:35:47ionelmcsetnosy: + ionelmc
2014-10-02 00:21:22BreamoreBoysetversions: + Python 3.4, Python 3.5, - Python 3.3
nosy: + BreamoreBoy

messages: + msg228143

type: behavior
2013-04-20 03:36:20nedbatcreate