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

Torben Hohn torben.hohn at linutronix.de
Wed Dec 9 11:41:17 CET 2020


On Wed, Oct 28, 2020 at 02:59:06PM +0100, bage at linutronix.de wrote:
> 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>

Reviewed-by: Torben Hohn <torben.hohn 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
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner


More information about the elbe-devel mailing list