[elbe-devel] [PATCH] python3: Replace IOError with more specific ones

bage at linutronix.de bage at linutronix.de
Wed Oct 28 14:59:06 CET 2020


From: Bastian Germann <bage at linutronix.de>

Replace IOError with PermissionError and FileExistsError and remove the
corresponding TODOs.

Signed-off-by: Bastian Germann <bage at linutronix.de>
---
 elbepack/commands/add.py  | 3 +--
 elbepack/commands/init.py | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/elbepack/commands/add.py b/elbepack/commands/add.py
index c1bbca260..2d2f446a9 100644
--- a/elbepack/commands/add.py
+++ b/elbepack/commands/add.py
@@ -39,8 +39,7 @@ def run_command(argv):
     try:
         xml.xml.write(xmlfile)
         sys.exit(0)
-    # TODO:py3 - Change exception to PermissionError
-    except IOError as E:
+    except PermissionError as E:
         print("Unable to truncate file %s: %s" % (xmlfile, E))
 
     sys.exit(20)
diff --git a/elbepack/commands/init.py b/elbepack/commands/init.py
index b0dba6af4..0e78d83d4 100644
--- a/elbepack/commands/init.py
+++ b/elbepack/commands/init.py
@@ -293,7 +293,6 @@ def run_command(argv):
         for src, dst in to_cpy:
             try:
                 os.makedirs(dst)
-            # TODO:py3 - Change exception to FileExistsError
-            except OSError:
+            except FileExistsError:
                 pass
             shutil.copy(src, dst)
-- 
2.28.0



More information about the elbe-devel mailing list