Skip to content
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

settrace docs are wrong about "c_call" events #61999

Closed
nedbat opened this issue Apr 20, 2013 · 9 comments
Closed

settrace docs are wrong about "c_call" events #61999

nedbat opened this issue Apr 20, 2013 · 9 comments
Labels
3.7 (EOL) end of life docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error

Comments

@nedbat
Copy link
Member

nedbat commented Apr 20, 2013

BPO 17799
Nosy @gvanrossum, @nedbat, @zhangyangyu
PRs
  • bpo-17799: Explain real behaviour of sys.settrace and sys.setprofile #4056
  • [3.6] bpo-17799: Explain real behaviour of sys.settrace and sys.setprofile (GH-4056) #5298
  • [2.7] bpo-17799: Explain real behaviour of sys.settrace and sys.setprofile (GH-4056) #5299
  • 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:

    assignee = None
    closed_at = <Date 2018-01-24.14:54:45.266>
    created_at = <Date 2013-04-20.03:36:20.117>
    labels = ['type-bug', '3.7', 'docs']
    title = 'settrace docs are wrong about "c_call" events'
    updated_at = <Date 2018-01-24.14:54:45.265>
    user = 'https://github.com/nedbat'

    bugs.python.org fields:

    activity = <Date 2018-01-24.14:54:45.265>
    actor = 'xiang.zhang'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2018-01-24.14:54:45.266>
    closer = 'xiang.zhang'
    components = ['Documentation']
    creation = <Date 2013-04-20.03:36:20.117>
    creator = 'nedbat'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 17799
    keywords = ['patch']
    message_count = 9.0
    messages = ['187406', '228143', '309797', '310383', '310393', '310396', '310587', '310598', '310599']
    nosy_count = 6.0
    nosy_names = ['gvanrossum', 'nedbat', 'ionelmc', 'docs@python', 'raylu', 'xiang.zhang']
    pr_nums = ['4056', '5298', '5299']
    priority = 'low'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue17799'
    versions = ['Python 2.7', 'Python 3.6', 'Python 3.7']

    @nedbat
    Copy link
    Member Author

    nedbat commented Apr 20, 2013

    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.

    @nedbat nedbat added the docs Documentation in the Doc dir label Apr 20, 2013
    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Oct 2, 2014

    @ned can you provide a patch for this?

    @BreamoreBoy BreamoreBoy mannequin added the type-bug An unexpected behavior, bug, or error label Oct 2, 2014
    @zhangyangyu
    Copy link
    Member

    Is there any reason not to respond to "c_call" events in trace function?

    @gvanrossum
    Copy link
    Member

    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.

    @zhangyangyu
    Copy link
    Member

    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

    @zhangyangyu zhangyangyu added the 3.7 (EOL) end of life label Jan 22, 2018
    @gvanrossum
    Copy link
    Member

    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.

    @zhangyangyu
    Copy link
    Member

    New changeset 131fd7f by Xiang Zhang (Pablo Galindo) in branch 'master':
    bpo-17799: Explain real behaviour of sys.settrace and sys.setprofile (bpo-4056)
    131fd7f

    @zhangyangyu
    Copy link
    Member

    New changeset fd844ef by Xiang Zhang in branch '3.6':
    bpo-17799: Explain real behaviour of sys.settrace and sys.setprofile (GH-4056) (bpo-5298)
    fd844ef

    @zhangyangyu
    Copy link
    Member

    New changeset e64a47b by Xiang Zhang in branch '2.7':
    bpo-17799: Explain real behaviour of sys.settrace and sys.setprofile (GH-4056). (bpo-5299)
    e64a47b

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants