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

inspect.getsource() examines incorrect target #84497

Closed
GrzegorzKraso mannequin opened this issue Apr 18, 2020 · 5 comments
Closed

inspect.getsource() examines incorrect target #84497

GrzegorzKraso mannequin opened this issue Apr 18, 2020 · 5 comments
Labels
3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@GrzegorzKraso
Copy link
Mannequin

GrzegorzKraso mannequin commented Apr 18, 2020

BPO 40317
Nosy @ammaraskar, @tirkarthi
Superseder
  • bpo-35113: inspect.getsource returns incorrect source for classes when class definition is part of multiline strings
  • Files
  • demo.py: Example
  • 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 2020-04-29.03:37:05.722>
    created_at = <Date 2020-04-18.11:50:37.511>
    labels = ['type-bug', 'library', '3.9']
    title = 'inspect.getsource() examines incorrect target'
    updated_at = <Date 2020-04-29.03:37:05.720>
    user = 'https://bugs.python.org/GrzegorzKraso'

    bugs.python.org fields:

    activity = <Date 2020-04-29.03:37:05.720>
    actor = 'xtreak'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-04-29.03:37:05.722>
    closer = 'xtreak'
    components = ['Library (Lib)']
    creation = <Date 2020-04-18.11:50:37.511>
    creator = 'Grzegorz Kraso\xc5\x84'
    dependencies = []
    files = ['49072']
    hgrepos = []
    issue_num = 40317
    keywords = []
    message_count = 5.0
    messages = ['366701', '366719', '366728', '367579', '367619']
    nosy_count = 3.0
    nosy_names = ['Grzegorz Kraso\xc5\x84', 'ammar2', 'xtreak']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '35113'
    type = 'behavior'
    url = 'https://bugs.python.org/issue40317'
    versions = ['Python 3.9']

    @GrzegorzKraso
    Copy link
    Mannequin Author

    GrzegorzKraso mannequin commented Apr 18, 2020

    Based on the attached example:

    Expected output:

    123
        class Number:
            payload = 123
    
    321
        class Number:
            payload = 321
    

    Actual output:

    123
        class Number:
            payload = 123
    
    321
        class Number:
            payload = 123
    

    Reproduced using:

    • Python 2.7.17
    • Python 3.7.7
    • Python 3.8.2

    @GrzegorzKraso GrzegorzKraso mannequin added 3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Apr 18, 2020
    @tirkarthi
    Copy link
    Member

    This will be resolved hopefully resolved using #10307 . Using my patch on the reproducer in the report.

    ./python bpo-40317.py
    123
    class Number:
    payload = 123

    321
    class Number:
    payload = 321

    @tirkarthi
    Copy link
    Member

    Fixed in master now with 696136b . This includes the change of show decorators for classes too to make it consistent with functions so it's not backported.

    @ammaraskar
    Copy link
    Member

    Did you mean to close this Karthik?

    @tirkarthi
    Copy link
    Member

    yes, thanks Ammar. Thanks Grzegorz for the report.

    @tirkarthi tirkarthi added 3.9 only security fixes and removed 3.7 (EOL) end of life 3.8 only security fixes labels Apr 29, 2020
    @tirkarthi tirkarthi added 3.9 only security fixes and removed 3.7 (EOL) end of life 3.8 only security fixes labels Apr 29, 2020
    @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.9 only security fixes 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