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

Support display of both __cause__ and __context__ #59010

Closed
ncoghlan opened this issue May 14, 2012 · 5 comments
Closed

Support display of both __cause__ and __context__ #59010

ncoghlan opened this issue May 14, 2012 · 5 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@ncoghlan
Copy link
Contributor

BPO 14805
Nosy @ncoghlan, @pjenvey, @meadori, @serhiy-storchaka
Dependencies
  • bpo-14133: improved PEP 409 implementation
  • 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 = None
    created_at = <Date 2012-05-14.12:00:38.996>
    labels = ['interpreter-core', 'type-feature', 'library']
    title = 'Support display of both __cause__ and __context__'
    updated_at = <Date 2013-04-20.19:16:46.060>
    user = 'https://github.com/ncoghlan'

    bugs.python.org fields:

    activity = <Date 2013-04-20.19:16:46.060>
    actor = 'pjenvey'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Interpreter Core', 'Library (Lib)']
    creation = <Date 2012-05-14.12:00:38.996>
    creator = 'ncoghlan'
    dependencies = ['14133']
    files = []
    hgrepos = []
    issue_num = 14805
    keywords = []
    message_count = 3.0
    messages = ['160609', '187446', '187451']
    nosy_count = 8.0
    nosy_names = ['ncoghlan', 'pjenvey', 'Arfrever', 'cvrebert', 'poke', 'meador.inge', 'serhiy.storchaka', 'isoschiz']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'needs patch'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue14805'
    versions = ['Python 3.3']

    @ncoghlan
    Copy link
    Contributor Author

    With PEP-415 accepted as the implementation of the "raise exc from None" syntax, it raises the prospect of exceptions with both __cause__ and __context__ set to non-None values, and __suppress_context__ set to False.

    The initial PEP-415 patch treats this case the same way PEP-409 did: it ignores __context__ if *either* __cause__ is not None *or* __suppress_context__ is True.

    This issue proposes that at least the default exception display routine and the display routine in the traceback module be updated to display the __context__ any time __suppress_context__ is False, even if __cause__ is also non-None.

    @ncoghlan ncoghlan added interpreter-core (Objects, Python, Grammar, and Parser dirs) stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels May 14, 2012
    @serhiy-storchaka
    Copy link
    Member

    And don't forget about print_exception() in Lib/idlelib/run.py.

    @pjenvey
    Copy link
    Member

    pjenvey commented Apr 20, 2013

    and the code module (after bpo-17442 is resolved)

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @stevendaprano
    Copy link
    Member

    stevendaprano commented May 16, 2022

    @gvanrossum says says that the current behaviour is by design, and this ticket should be closed.

    I asked why the design is intended (since neither the PEP nor the documentation explains) and Guido says I should ask it here.

    @gvanrossum
    Copy link
    Member

    I suppose the reason is that if you take both cause and context into account, you end up with a tree -- each cause may itself have another cause and another context, and ditto for each context. Displaying such a tree (where each node is a traceback that could be many stack frames deep) would be complicated, and probably produce more confusion than understanding in most users. Plus, because cause is set explicitly while context is implicit, it stands to reason that when the failing code indicates a context, the cause is not important enough to display.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs) stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants