Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

inspect.BlockFinder handles tokenize.NEWLINE too strictly #139783

Copy link
Copy link
@BabakkGraphcore

Description

@BabakkGraphcore
Issue body actions

Bug report

Bug description:

In python 3.13.8 calling inspect.getsourcelines on a decorated function with a comment between the decorator and the name only returns the function declaration, the body is skipped.

import inspect

def dummy(fn):
    return fn

@dummy
def test1(a, b):
    return a

@dummy
#comment
def test2(a, b):
    return a

print(inspect.getsourcelines(test1))
print("------------------")
print(inspect.getsourcelines(test2))

returns

(['@dummy\n', 'def test1(a, b):\n', '    return a\n'], 6)
------------------
(['@dummy\n', '#comment\n', 'def test2(a, b):\n'], 10)

the source of test2 is incomplete and missing the return statement.

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs

Reactions are currently unavailable

Metadata

Metadata

Labels

3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
No fields configured for issues without a type.

Projects

Status
Done
Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.