linecache.py was still struggling with unicode vs. non-unicode.

This commit is contained in:
Guido van Rossum 2007-05-22 00:12:45 +00:00
parent 390bd7c67e
commit 94ca1c620e
1 changed files with 3 additions and 2 deletions

View File

@ -139,8 +139,9 @@ def updatecache(filename, module_globals=None):
coding = m.group(1)
break
try:
lines = [unicode(line, coding) for line in lines]
except UnicodeError:
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