Skip to content

getsource cannot get correct source code in decorator with REPL #711

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

Open
silence974 opened this issue Apr 15, 2025 · 0 comments
Open

getsource cannot get correct source code in decorator with REPL #711

silence974 opened this issue Apr 15, 2025 · 0 comments

Comments

@silence974
Copy link

import dill.source


def d(f):
    source = dill.source.getsource(f)
    print(source)
    return f


@d
def my_func(x):
    y = x+2
    return y*2

execute this code in REPL, will get

@d
def my_func(x):
    y = x+2

but expect this result

@d
def my_func(x):
    y = x+2
    return y*2

Environment: python 3.8.13 on Linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant