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
86d1ac43
Commit
86d1ac43
authored
Dec 12, 2008
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revert r67713. it causes build problems
parent
2bed9abd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
4 deletions
+20
-4
Lib/linecache.py
Lib/linecache.py
+20
-4
No files found.
Lib/linecache.py
View file @
86d1ac43
...
...
@@ -7,7 +7,7 @@ that name.
import
sys
import
os
import
tokeniz
e
import
r
e
__all__
=
[
"getline"
,
"clearcache"
,
"checkcache"
]
...
...
@@ -121,11 +121,27 @@ def updatecache(filename, module_globals=None):
pass
else
:
# No luck
## print '*** Cannot stat', filename, ':', msg
return
[]
with
open
(
fullname
,
'rb'
)
as
fp
:
coding
,
line
=
tokenize
.
detect_encoding
(
fp
.
readline
)
with
open
(
fullname
,
'r'
,
encoding
=
coding
)
as
fp
:
## print("Refreshing cache for %s..." % fullname)
try
:
fp
=
open
(
fullname
,
'rU'
)
lines
=
fp
.
readlines
()
fp
.
close
()
except
Exception
as
msg
:
## print '*** Cannot open', fullname, ':', msg
return
[]
coding
=
"utf-8"
for
line
in
lines
[:
2
]:
m
=
re
.
search
(
r"coding[:=]\
s*([-
\w.]+)"
,
line
)
if
m
:
coding
=
m
.
group
(
1
)
break
try
:
lines
=
[
line
if
isinstance
(
line
,
str
)
else
str
(
line
,
coding
)
for
line
in
lines
]
except
:
pass
# Hope for the best
size
,
mtime
=
stat
.
st_size
,
stat
.
st_mtime
cache
[
filename
]
=
size
,
mtime
,
lines
,
fullname
return
lines
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