From: Guido van Rossum Date: Tue, 22 May 2007 00:12:45 +0000 (+0000) Subject: linecache.py was still struggling with unicode vs. non-unicode. X-Git-Tag: v3.0a1~907 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=94ca1c620ebc63b0860579835f2c16fe056e1225;p=thirdparty%2FPython%2Fcpython.git linecache.py was still struggling with unicode vs. non-unicode. --- diff --git a/Lib/linecache.py b/Lib/linecache.py index 9a16acd25995..77e3ab719706 100644 --- a/Lib/linecache.py +++ b/Lib/linecache.py @@ -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