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
0c445796
Commit
0c445796
authored
Mar 23, 2002
by
Neil Schemenauer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use linecache for loading source code. Closes SF patch 490374.
parent
2c2ae458
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
7 deletions
+5
-7
Lib/inspect.py
Lib/inspect.py
+5
-7
No files found.
Lib/inspect.py
View file @
0c445796
...
...
@@ -27,7 +27,7 @@ Here are some of the useful functions provided by this module:
__author__
=
'Ka-Ping Yee <ping@lfw.org>'
__date__
=
'1 Jan 2001'
import
sys
,
os
,
types
,
string
,
re
,
dis
,
imp
,
tokenize
import
sys
,
os
,
types
,
string
,
re
,
dis
,
imp
,
tokenize
,
linecache
# ----------------------------------------------------------- type-checking
def
ismodule
(
object
):
...
...
@@ -381,12 +381,10 @@ def findsource(object):
or code object. The source code is returned as a list of all the lines
in the file and the line number indexes a line in that list. An IOError
is raised if the source code cannot be retrieved."""
try
:
file
=
open
(
getsourcefile
(
object
)
)
except
(
TypeError
,
IOError
)
:
file
=
getsourcefile
(
object
)
or
getfile
(
object
)
lines
=
linecache
.
getlines
(
file
)
if
not
lines
:
raise
IOError
,
'could not get source code'
lines
=
file
.
readlines
()
file
.
close
()
if
ismodule
(
object
):
return
lines
,
0
...
...
@@ -706,7 +704,7 @@ def getframeinfo(frame, context=1):
if not isframe(frame):
raise TypeError, '
arg
is
not
a
frame
or
traceback
object
'
filename = getsourcefile(frame)
filename = getsourcefile(frame)
or getfile(frame)
lineno = getlineno(frame)
if context > 0:
start = lineno - 1 - context//2
...
...
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