mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Issue #10335: Add tokenize.open(), detect the file encoding using
tokenize.detect_encoding() and open it in read only mode.
This commit is contained in:
parent
ae4836df6d
commit
58c0752a33
8 changed files with 54 additions and 22 deletions
|
|
@ -123,9 +123,7 @@ def updatecache(filename, module_globals=None):
|
|||
else:
|
||||
return []
|
||||
try:
|
||||
with open(fullname, 'rb') as fp:
|
||||
coding, line = tokenize.detect_encoding(fp.readline)
|
||||
with open(fullname, 'r', encoding=coding) as fp:
|
||||
with tokenize.open(fullname) as fp:
|
||||
lines = fp.readlines()
|
||||
except IOError:
|
||||
return []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue