cpython: ad9cc6124a19 (original) (raw)
Mercurial > cpython
changeset 92593:ad9cc6124a19
inspect: Fix getsource() to support decorated functions. Issue #1764286. Patch by Claudiu Popa. [#1764286]
Yury Selivanov yselivanov@sprymix.com | |
---|---|
date | Fri, 26 Sep 2014 17:34:54 -0400 |
parents | bbe57429eba0 |
children | d43d4d4ebf2c |
files | Lib/inspect.py Lib/test/inspect_fodder2.py Lib/test/test_inspect.py Misc/NEWS |
diffstat | 4 files changed, 20 insertions(+), 0 deletions(-)[+] [-] Lib/inspect.py 1 Lib/test/inspect_fodder2.py 13 Lib/test/test_inspect.py 3 Misc/NEWS 3 |
line wrap: on
line diff
--- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -817,6 +817,7 @@ def getsourcelines(object): corresponding to the object and the line number indicates where in the original source file the first line of code was found. An OSError is raised if the source code cannot be retrieved."""
--- a/Lib/test/inspect_fodder2.py +++ b/Lib/test/inspect_fodder2.py @@ -109,3 +109,16 @@ def annotated(arg1: list): #line 109 def keyword_only_arg(*, arg): pass + +from functools import wraps + +def decorator(func):
+ +#line 121 +@decorator +def real():
--- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -377,6 +377,9 @@ class TestDecorators(GetSourceBase): def test_replacing_decorator(self): self.assertSourceEqual(mod2.gone, 9, 10)
+ class TestOneliners(GetSourceBase): fodderModule = mod2 def test_oneline_lambda(self):
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Release date: TBA Core and Builtins ----------------- +- Issue #1764286: Fix inspect.getsource() to support decorated functions.