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.print_last fails #46168

Closed
tzot mannequin opened this issue Jan 17, 2008 · 3 comments
Closed

traceback.print_last fails #46168

tzot mannequin opened this issue Jan 17, 2008 · 3 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@tzot
Copy link
Mannequin

tzot mannequin commented Jan 17, 2008

BPO 1860
Nosy @amauryfa
Files
  • test_tb_print_last.py: A test displaying the bad behaviour
  • traceback_patch.diff: Patch for traceback.print_last()
  • 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 2008-01-17.13:59:20.050>
    created_at = <Date 2008-01-17.13:26:57.555>
    labels = ['invalid', 'type-bug', 'library']
    title = 'traceback.print_last fails'
    updated_at = <Date 2008-01-17.13:59:20.038>
    user = 'https://bugs.python.org/tzot'

    bugs.python.org fields:

    activity = <Date 2008-01-17.13:59:20.038>
    actor = 'amaury.forgeotdarc'
    assignee = 'none'
    closed = True
    closed_date = <Date 2008-01-17.13:59:20.050>
    closer = 'amaury.forgeotdarc'
    components = ['Library (Lib)']
    creation = <Date 2008-01-17.13:26:57.555>
    creator = 'tzot'
    dependencies = []
    files = ['9193', '9194']
    hgrepos = []
    issue_num = 1860
    keywords = []
    message_count = 3.0
    messages = ['60028', '60029', '60030']
    nosy_count = 2.0
    nosy_names = ['tzot', 'amaury.forgeotdarc']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue1860'
    versions = ['Python 2.6', 'Python 2.5']

    @tzot
    Copy link
    Mannequin Author

    tzot mannequin commented Jan 17, 2008

    traceback.print_last() depends on the existence of sys.last_type,
    sys.last_value, sys.last_traceback, which don't always exist when
    called. See attached example file. I will shortly send the patch for
    Lib/traceback.py

    @tzot tzot mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jan 17, 2008
    @tzot
    Copy link
    Mannequin Author

    tzot mannequin commented Jan 17, 2008

    I haven't submitted a patch since the transition from sf.net to
    bugs.python.org; I assume that I don't have to open a new patch for
    this, but if I have to, please let me know and I will gladly do it.

    The unified diff is attached; the test example I issued works with the
    patched version.

    @amauryfa
    Copy link
    Member

    traceback.print_last() depends on the existence of sys.last_type
    Yes, that is exactly as documented:

    >>> help(traceback.print_last)
    Help on function print_last in module traceback:
    print_last(limit=None, file=None)
        This is a shorthand for 'print_exception(sys.last_type,
        sys.last_value, sys.last_traceback, limit, file)'.

    Furthermore, in the doc:
    http://docs.python.org/dev/library/sys.html#sys.last_type
    "... they are set when an exception is not handled ..."
    In your script, you *are* handling the exception.
    Your script really should use traceback.print_exc() instead.
    BTW, your patch basically makes print_last() identical to print_exc()...

    @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-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant