2
0
Эх сурвалжийг харах

decodetree: Do not remove output_file from /dev

Nor report any PermissionError on remove.
The primary purpose is testing with -o /dev/null.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Richard Henderson 2 жил өмнө
parent
commit
036cc75ca0
1 өөрчлөгдсөн 6 нэмэгдсэн , 1 устгасан
  1. 6 1
      scripts/decodetree.py

+ 6 - 1
scripts/decodetree.py

@@ -71,7 +71,12 @@ def error_with_file(file, lineno, *args):
 
     if output_file and output_fd:
         output_fd.close()
-        os.remove(output_file)
+        # Do not try to remove e.g. -o /dev/null
+        if not output_file.startswith("/dev"):
+            try:
+                os.remove(output_file)
+            except PermissionError:
+                pass
     exit(0 if testforerror else 1)
 # end error_with_file