Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
081bbf6b
Commit
081bbf6b
authored
Sep 26, 2014
by
Yury Selivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inspect: Fix getsource() to support decorated functions.
Issue #1764286. Patch by Claudiu Popa.
parent
2c0a9160
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
0 deletions
+20
-0
Lib/inspect.py
Lib/inspect.py
+1
-0
Lib/test/inspect_fodder2.py
Lib/test/inspect_fodder2.py
+13
-0
Lib/test/test_inspect.py
Lib/test/test_inspect.py
+3
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/inspect.py
View file @
081bbf6b
...
...
@@ -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."""
object
=
unwrap
(
object
)
lines
,
lnum
=
findsource
(
object
)
if
ismodule
(
object
):
return
lines
,
0
...
...
Lib/test/inspect_fodder2.py
View file @
081bbf6b
...
...
@@ -109,3 +109,16 @@ def annotated(arg1: list):
#line 109
def
keyword_only_arg
(
*
,
arg
):
pass
from
functools
import
wraps
def
decorator
(
func
):
@
wraps
(
func
)
def
fake
():
return
42
return
fake
#line 121
@
decorator
def
real
():
return
20
Lib/test/test_inspect.py
View file @
081bbf6b
...
...
@@ -377,6 +377,9 @@ class TestDecorators(GetSourceBase):
def
test_replacing_decorator
(
self
):
self
.
assertSourceEqual
(
mod2
.
gone
,
9
,
10
)
def
test_getsource_unwrap
(
self
):
self
.
assertSourceEqual
(
mod2
.
real
,
122
,
124
)
class
TestOneliners
(
GetSourceBase
):
fodderModule
=
mod2
def
test_oneline_lambda
(
self
):
...
...
Misc/NEWS
View file @
081bbf6b
...
...
@@ -10,6 +10,9 @@ Release date: TBA
Core and Builtins
-----------------
- Issue #1764286: Fix inspect.getsource() to support decorated functions.
Patch by Claudiu Popa.
- Issue #18554: os.__all__ includes posix functions.
- Issue #21391: Use os.path.abspath in the shutil module.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment