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

traceback module has no way to show locals #67125

Closed
rbtcollins opened this issue Nov 25, 2014 · 17 comments
Closed

traceback module has no way to show locals #67125

rbtcollins opened this issue Nov 25, 2014 · 17 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@rbtcollins
Copy link
Member

rbtcollins commented Nov 25, 2014

BPO 22936
Nosy @ncoghlan, @rbtcollins, @ezio-melotti
Dependencies
  • bpo-17911: traceback: add a new thin class storing a traceback without storing local variables
  • Files
  • issue-22936-1.patch
  • issue-22936-2.patch
  • issue-22936-3.patch
  • issue-22936-4.patch
  • issue-22936-5.patch
  • 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 2015-08-26.00:13:03.473>
    created_at = <Date 2014-11-25.02:05:27.694>
    labels = ['type-feature', 'library']
    title = 'traceback module has no way to show locals'
    updated_at = <Date 2015-08-26.00:13:03.472>
    user = 'https://github.com/rbtcollins'

    bugs.python.org fields:

    activity = <Date 2015-08-26.00:13:03.472>
    actor = 'rbcollins'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-08-26.00:13:03.473>
    closer = 'rbcollins'
    components = ['Library (Lib)']
    creation = <Date 2014-11-25.02:05:27.694>
    creator = 'rbcollins'
    dependencies = ['17911']
    files = ['37875', '38008', '38333', '38336', '38349']
    hgrepos = []
    issue_num = 22936
    keywords = ['patch']
    message_count = 17.0
    messages = ['231628', '231630', '231738', '234799', '235366', '237218', '237243', '237244', '237246', '237262', '237267', '237298', '237308', '237314', '237320', '237326', '249169']
    nosy_count = 7.0
    nosy_names = ['ncoghlan', 'rbcollins', 'ezio.melotti', 'cvrebert', 'BreamoreBoy', 'python-dev', 'n']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue22936'
    versions = ['Python 3.6']

    @rbtcollins
    Copy link
    Member Author

    rbtcollins commented Nov 25, 2014

    From testing-cabal/testtools#111 - any code that is data dependent can be hard to diagnose from a backtrace alone. Many unittest and server environments address this by doing custom tracebacks that include locals.

    To address this in unittest, we need to add a similar capacity to traceback, and then use it from unittest (as we can't just depend on a module from PyPI in the stdlib).

    @rbtcollins rbtcollins added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Nov 25, 2014
    @rbtcollins
    Copy link
    Member Author

    rbtcollins commented Nov 25, 2014

    See http://bugs.python.org/issue22936 for the unittest aspect of this.

    @gvanrossum
    Copy link
    Member

    gvanrossum commented Nov 27, 2014

    Check out the cgitb stdlib module.

    @rbtcollins
    Copy link
    Member Author

    rbtcollins commented Jan 26, 2015

    First cut implementation. I'm sure there is lots we can add, but this will make things nicer in and of itself.

    Thanks for the pointer to cgitb, I've skimmed it and its definitely much more comprehensive. I'm not entirely sure about the best way to glue it and the new traceback API together; or even if thats needed.

    @rbtcollins
    Copy link
    Member Author

    rbtcollins commented Feb 3, 2015

    updated with the latest 17911 patch basis.

    @rbtcollins
    Copy link
    Member Author

    rbtcollins commented Mar 4, 2015

    And now updated to HEAD as 17911 has been committed.

    @ncoghlan
    Copy link
    Contributor

    ncoghlan commented Mar 5, 2015

    Latest patch (issue-22936-4.patch) looks good to me!

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 5, 2015

    New changeset 50741316dd3a by Robert Collins in branch 'default':
    Issue bpo-22936: Make it possible to show local variables in tracebacks.
    https://hg.python.org/cpython/rev/50741316dd3a

    @ezio-melotti
    Copy link
    Member

    ezio-melotti commented Mar 5, 2015

    In the patch you made some args kw-only.
    Isn't that backward incompatible in case someone was passing them by position?

    @ncoghlan
    Copy link
    Contributor

    ncoghlan commented Mar 5, 2015

    It's only the new APIs just introduced in issue bpo-17911 that changed to kwonly arguments.

    We missed that they should really be kwonly in the original review, but it become more obvious in this patch, as it added a second feature toggle to indicate whether or not to capture the locals.

    @ezio-melotti
    Copy link
    Member

    ezio-melotti commented Mar 5, 2015

    You are right -- I didn't notice the versionadded in the docs.
    Sorry for the noise.

    @rbtcollins
    Copy link
    Member Author

    rbtcollins commented Mar 5, 2015

    No worries. BTW there is one more patch needed to close this issue - adding the feature to unittest. I'm working that up now.

    @rbtcollins
    Copy link
    Member Author

    rbtcollins commented Mar 6, 2015

    And the unittest patch.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 6, 2015

    New changeset b4a26b28f5b3 by Robert Collins in branch 'default':
    Issue bpo-22936: Allow showing local variables in unittest errors.
    https://hg.python.org/cpython/rev/b4a26b28f5b3

    @ncoghlan
    Copy link
    Contributor

    ncoghlan commented Mar 6, 2015

    I just filed issue bpo-23597 as a potential further follow-up to this, which would be to also add support for displaying local variables directly to the logging module.

    However, that has some additional security implications, so I'm entirely convinced it's a good idea yet. See the new RFE for more details.

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Mar 6, 2015

    msg237320 "...so I'm *NOT* entirely convinced..."? :)

    @rbtcollins
    Copy link
    Member Author

    rbtcollins commented Aug 26, 2015

    This itself is fixed.

    @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
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants