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
26da1871
Commit
26da1871
authored
May 21, 2010
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify and modernize updatecache()
parent
b9e7c012
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
12 deletions
+10
-12
Lib/linecache.py
Lib/linecache.py
+10
-12
No files found.
Lib/linecache.py
View file @
26da1871
...
...
@@ -72,13 +72,13 @@ def updatecache(filename, module_globals=None):
if
filename
in
cache
:
del
cache
[
filename
]
if
not
filename
or
filename
[
0
]
+
filename
[
-
1
]
==
'<>'
:
if
not
filename
or
(
filename
.
startswith
(
'<'
)
and
filename
.
endswith
(
'>'
))
:
return
[]
fullname
=
filename
try
:
stat
=
os
.
stat
(
fullname
)
except
os
.
error
,
msg
:
except
OSError
:
basename
=
filename
# Try for a __loader__, if available
...
...
@@ -115,20 +115,18 @@ def updatecache(filename, module_globals=None):
fullname
=
os
.
path
.
join
(
dirname
,
basename
)
except
(
TypeError
,
AttributeError
):
# Not sufficiently string-like to do anything useful with.
continue
try
:
stat
=
os
.
stat
(
fullname
)
break
except
os
.
error
:
pass
else
:
try
:
stat
=
os
.
stat
(
fullname
)
break
except
os
.
error
:
pass
else
:
return
[]
try
:
fp
=
open
(
fullname
,
'rU'
)
lines
=
fp
.
readlines
()
fp
.
close
()
except
IOError
,
msg
:
with
open
(
fullname
,
'rU'
)
as
fp
:
lines
=
fp
.
readlines
()
except
IOError
:
return
[]
if
lines
and
not
lines
[
-
1
].
endswith
(
'
\
n
'
):
lines
[
-
1
]
+=
'
\
n
'
...
...
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