diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-11-09 01:08:59 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-11-09 01:08:59 (GMT) |
commit | 58c0752a33253641c1423fac2d4ef3f623fbcb46 (patch) | |
tree | 2e2ada02342f78d3cc58a4fe23082818c4025b1b /Lib/linecache.py | |
parent | ae4836df6d0ea92d778ef30bd37417d048fc37fc (diff) | |
download | cpython-58c0752a33253641c1423fac2d4ef3f623fbcb46.zip cpython-58c0752a33253641c1423fac2d4ef3f623fbcb46.tar.gz cpython-58c0752a33253641c1423fac2d4ef3f623fbcb46.tar.bz2 |
Issue #10335: Add tokenize.open(), detect the file encoding using
tokenize.detect_encoding() and open it in read only mode.
Diffstat (limited to 'Lib/linecache.py')
-rw-r--r-- | Lib/linecache.py | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/Lib/linecache.py b/Lib/linecache.py index 974b1d9..c3f2c3f 100644 --- a/Lib/linecache.py +++ b/Lib/linecache.py @@ -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 [] |