[Python-3000-checkins] r55499 - python/branches/py3k-struni/Lib/linecache.py

guido.van.rossum python-3000-checkins at python.org
Tue May 22 02:12:46 CEST 2007


Author: guido.van.rossum
Date: Tue May 22 02:12:45 2007
New Revision: 55499

Modified:
   python/branches/py3k-struni/Lib/linecache.py
Log:
linecache.py was still struggling with unicode vs. non-unicode.


Modified: python/branches/py3k-struni/Lib/linecache.py
==============================================================================
--- python/branches/py3k-struni/Lib/linecache.py	(original)
+++ python/branches/py3k-struni/Lib/linecache.py	Tue May 22 02:12:45 2007
@@ -139,8 +139,9 @@
             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


More information about the Python-3000-checkins mailing list