[Lldb-commits] [lldb] r116621 - /lldb/trunk/test/lldbutil.py

Johnny Chen johnny.chen at apple.com
Fri Oct 15 14:18:07 PDT 2010


Author: johnny
Date: Fri Oct 15 16:18:07 2010
New Revision: 116621

URL: http://llvm.org/viewvc/llvm-project?rev=116621&view=rev
Log:
Make sure to close the string buffer when finished.

Modified:
    lldb/trunk/test/lldbutil.py

Modified: lldb/trunk/test/lldbutil.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=116621&r1=116620&r2=116621&view=diff
==============================================================================
--- lldb/trunk/test/lldbutil.py (original)
+++ lldb/trunk/test/lldbutil.py Fri Oct 15 16:18:07 2010
@@ -4,7 +4,7 @@
 
 import lldb
 import sys
-import StringIO
+import cStringIO
 
 ################################################
 #                                              #
@@ -167,7 +167,7 @@
 def PrintStackTrace(thread, string_buffer = False):
     """Prints a simple stack trace of this thread."""
 
-    output = StringIO.StringIO() if string_buffer else sys.stdout
+    output = cStringIO.StringIO() if string_buffer else sys.stdout
     target = thread.GetProcess().GetTarget()
 
     depth = thread.GetNumFrames()
@@ -196,13 +196,14 @@
                 num=i, addr=load_addr, mod=mods[i], func=funcs[i], file=files[i], line=lines[i])
 
     if string_buffer:
-        return output.getvalue()
+        with output:
+            return output.getvalue()
 
 
 def PrintStackTraces(process, string_buffer = False):
     """Prints the stack traces of all the threads."""
 
-    output = StringIO.StringIO() if string_buffer else sys.stdout
+    output = cStringIO.StringIO() if string_buffer else sys.stdout
 
     print >> output, "Stack traces for " + repr(process)
 
@@ -210,4 +211,5 @@
         print >> output, PrintStackTrace(process.GetThreadAtIndex(i), string_buffer=True)
 
     if string_buffer:
-        return output.getvalue()
+        with output:
+            return output.getvalue()





More information about the lldb-commits mailing list