[Lldb-commits] [PATCH] Ignore IOError from missing child.log.

Chaoren Lin chaorenl at google.com
Mon Apr 6 10:46:38 PDT 2015


================
Comment at: test/tools/lldb-mi/lldbmi_testcase.py:28-31
@@ -27,3 +27,6 @@
             print "\n\nContents of %s:" % self.mylog
-            print open(self.mylog, "r").read()
+            try:
+                print open(self.mylog, "r").read()
+            except IOError:
+                pass
         Base.tearDown(self)
----------------
ki.stfu wrote:
> I'd prefer to not use exceptions where it's not needed. Can we change it to the following?
> ```
> import os.path
> if os.path.exists(self.mylog):
>     print open(self.mylog, "r").read()
> ```
I thought EAFP is the preferred way to do things in python?

http://en.wikibooks.org/wiki/Python_Programming/Idioms#Principles

It's also possible for child.log to get removed (by another Mi test perhaps?) between the check and the read.

http://reviews.llvm.org/D8843

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the lldb-commits mailing list