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
4f4913b3
Commit
4f4913b3
authored
Jul 23, 2015
by
Yury Selivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #24485: Revert backwards compatibility breaking changes of #21217.
parent
4887523c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
22 deletions
+14
-22
Lib/inspect.py
Lib/inspect.py
+2
-18
Lib/test/inspect_fodder2.py
Lib/test/inspect_fodder2.py
+7
-0
Lib/test/test_inspect.py
Lib/test/test_inspect.py
+5
-0
Misc/NEWS
Misc/NEWS
+0
-4
No files found.
Lib/inspect.py
View file @
4f4913b3
...
...
@@ -902,14 +902,6 @@ def getblock(lines):
pass
return
lines
[:
blockfinder
.
last
]
def
_line_number_helper
(
code_obj
,
lines
,
lnum
):
"""Return a list of source lines and starting line number for a code object.
The arguments must be a code object with lines and lnum from findsource.
"""
_
,
end_line
=
list
(
dis
.
findlinestarts
(
code_obj
))[
-
1
]
return
lines
[
lnum
:
end_line
],
lnum
+
1
def
getsourcelines
(
object
):
"""Return a list of source lines and starting line number for an object.
...
...
@@ -921,16 +913,8 @@ def getsourcelines(object):
object
=
unwrap
(
object
)
lines
,
lnum
=
findsource
(
object
)
if
ismodule
(
object
):
return
lines
,
0
elif
iscode
(
object
):
return
_line_number_helper
(
object
,
lines
,
lnum
)
elif
isfunction
(
object
):
return
_line_number_helper
(
object
.
__code__
,
lines
,
lnum
)
elif
ismethod
(
object
):
return
_line_number_helper
(
object
.
__func__
.
__code__
,
lines
,
lnum
)
else
:
return
getblock
(
lines
[
lnum
:]),
lnum
+
1
if
ismodule
(
object
):
return
lines
,
0
else
:
return
getblock
(
lines
[
lnum
:]),
lnum
+
1
def
getsource
(
object
):
"""Return the text of the source code for an object.
...
...
Lib/test/inspect_fodder2.py
View file @
4f4913b3
...
...
@@ -130,3 +130,10 @@ def decorator(func):
@
decorator
def
real
():
return
20
#line 134
class
cls135
:
def
func136
():
def
func137
():
never_reached1
never_reached2
Lib/test/test_inspect.py
View file @
4f4913b3
...
...
@@ -464,6 +464,7 @@ class TestDecorators(GetSourceBase):
def
test_getsource_unwrap
(
self
):
self
.
assertSourceEqual
(
mod2
.
real
,
130
,
132
)
@
unittest
.
expectedFailure
def
test_decorator_with_lambda
(
self
):
self
.
assertSourceEqual
(
mod2
.
func114
,
113
,
115
)
...
...
@@ -563,6 +564,10 @@ class TestBuggyCases(GetSourceBase):
def
test_getsource_on_method
(
self
):
self
.
assertSourceEqual
(
mod2
.
ClassWithMethod
.
method
,
118
,
119
)
def
test_nested_func
(
self
):
self
.
assertSourceEqual
(
mod2
.
cls135
.
func136
,
136
,
139
)
class
TestNoEOL
(
GetSourceBase
):
def
setUp
(
self
):
self
.
tempdir
=
TESTFN
+
'_dir'
...
...
Misc/NEWS
View file @
4f4913b3
...
...
@@ -551,10 +551,6 @@ Library
- Issue #23342: Add a subprocess.run() function than returns a CalledProcess
instance for a more consistent API than the existing call* functions.
- Issue #21217: inspect.getsourcelines() now tries to compute the start and end
lines from the code object, fixing an issue when a lambda function is used as
decorator argument. Patch by Thomas Ballinger and Allison Kaptur.
- Issue #24521: Fix possible integer overflows in the pickle module.
- Issue #22931: Allow '
[
' and '
]
' in cookie values.
...
...
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