This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author crusaderky
Recipients crusaderky
Date 2019-11-19.21:37:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1574199462.47.0.0804409972746.issue38854@roundup.psfhosted.org>
In-reply-to
Content
Python 3.7.5 and 3.8.0
A decorator causes inspect.getsource() to return clipped output:



from collections import defaultdict
from functools import wraps
import inspect


def foo(*args):
    def decorator(func):
        @wraps(func)
        def wrapper():
            pass
        return wrapper
    return decorator


@foo(dict(), defaultdict(lambda: 1))
def f():
    pass


print(inspect.getsource(f))



Output:

@foo(dict(), defaultdict(lambda: 1))

Expected output:

@foo(dict(), defaultdict(lambda: 1))
def f():
    pass


These changes to the decorator parameters cause the problem to disappear:

- @foo({}, defaultdict(lambda: 1))
- @foo(dict(), defaultdict(list))
History
Date User Action Args
2019-11-19 21:37:42crusaderkysetrecipients: + crusaderky
2019-11-19 21:37:42crusaderkysetmessageid: <1574199462.47.0.0804409972746.issue38854@roundup.psfhosted.org>
2019-11-19 21:37:42crusaderkylinkissue38854 messages
2019-11-19 21:37:42crusaderkycreate