[pypy-svn] r71533 - pypy/trunk/pypy/tool

arigo at codespeak.net arigo at codespeak.net
Sat Feb 27 16:51:21 CET 2010


Author: arigo
Date: Sat Feb 27 16:51:20 2010
New Revision: 71533

Modified:
   pypy/trunk/pypy/tool/logparser.py
Log:
Sanitize.


Modified: pypy/trunk/pypy/tool/logparser.py
==============================================================================
--- pypy/trunk/pypy/tool/logparser.py	(original)
+++ pypy/trunk/pypy/tool/logparser.py	Sat Feb 27 16:51:20 2010
@@ -9,7 +9,6 @@
 import autopath
 import sys, re
 from pypy.rlib.debug import DebugLog
-import bz2
 
 def parse_log_file(filename):
     r_start = re.compile(r"\[([0-9a-fA-F]+)\] \{([\w-]+)$")
@@ -19,10 +18,15 @@
     time_decrase = False
     performance_log = True
     nested = 0
-    try:
-        lines = bz2.BZ2File(filename, 'r').readlines()
-    except:
-        lines = open(filename, 'r').readlines()
+    #
+    f = open(filename, 'r')
+    if f.read(2) == 'BZ':
+        f.close()
+        import bz2
+        f = bz2.BZ2File(filename, 'r')
+    lines = f.readlines()
+    f.close()
+    #
     for line in lines:
         line = line.rstrip()
         match = r_start.match(line)



More information about the Pypy-commit mailing list