[New-bugs-announce] [issue1685] linecache .updatecache fails on utf8 encoded files

PyScripter report at bugs.python.org
Sat Dec 22 06:17:15 CET 2007

New submission from PyScripter:

linecache.updatecache works as follows after it finds a module name:

fp = open(fullname, 'rU')
lines = fp.readlines()

It then tries to detect a file encoding comment...

The problem is that readlines fails with a UnicodeDecodeError if the 
file is utf8 encoded, the preferred locale encoding is something else 
and the file contains characters that cannot be decoded.

Instead the function should:
a) read the raw data into a bytes object 
b)then search for a file encoding comment and
c)use one if found else use utf8 since this is not the default file 

components: Library (Lib)
messages: 58958
nosy: pyscripter
severity: normal
status: open
title: linecache .updatecache fails on utf8 encoded files
versions: Python 3.0

Tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list