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

Line numbers reported by extract_stack are offset by the #-*- encoding line #47081

Closed
ddvoinikov mannequin opened this issue May 12, 2008 · 2 comments
Closed

Line numbers reported by extract_stack are offset by the #-*- encoding line #47081

ddvoinikov mannequin opened this issue May 12, 2008 · 2 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@ddvoinikov
Copy link
Mannequin

ddvoinikov mannequin commented May 12, 2008

BPO 2832
Nosy @pitrou, @vstinner
Superseder
  • bpo-2384: [Py3k] line number is wrong after encoding declaration
  • 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-09-27.15:32:44.358>
    created_at = <Date 2008-05-12.04:52:03.637>
    labels = ['type-bug', 'library']
    title = 'Line numbers reported by extract_stack are offset by the #-*- encoding line'
    updated_at = <Date 2008-09-27.15:32:44.358>
    user = 'https://bugs.python.org/ddvoinikov'

    bugs.python.org fields:

    activity = <Date 2008-09-27.15:32:44.358>
    actor = 'benjamin.peterson'
    assignee = 'none'
    closed = True
    closed_date = <Date 2008-09-27.15:32:44.358>
    closer = 'benjamin.peterson'
    components = ['Library (Lib)']
    creation = <Date 2008-05-12.04:52:03.637>
    creator = 'ddvoinikov'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 2832
    keywords = []
    message_count = 2.0
    messages = ['66708', '73927']
    nosy_count = 3.0
    nosy_names = ['pitrou', 'vstinner', 'ddvoinikov']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = None
    status = 'closed'
    superseder = '2384'
    type = 'behavior'
    url = 'https://bugs.python.org/issue2832'
    versions = ['Python 3.0']

    @ddvoinikov
    Copy link
    Mannequin Author

    ddvoinikov mannequin commented May 12, 2008

    Stack trace information extracted with traceback.extract_stack is
    incorrect in that the #-*- line causes double counting. For example:

    #comment
    from traceback import extract_stack
    print("this is line", extract_stack()[-1][1])

    prints 'this is line 3', but

    #comment
    #-*- coding: windows-1251 -*-
    from traceback import extract_stack
    print("this is line", extract_stack()[-1][1])

    prints 'this is line 6'

    @ddvoinikov ddvoinikov mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels May 12, 2008
    @vstinner
    Copy link
    Member

    This bug is a duplicate of the bpo-2384: I tried your example with
    the patch tokenizer-coding-2.patch and your bug is fixed:

    • first example (no coding): this is line 3
    • second example (with coding): this is line 4

    @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

    2 participants