[elbe-devel] [PATCH 15/75] commands add: Fix Pylint

Torben Hohn torben.hohn at linutronix.de
Fri May 29 11:30:43 CEST 2020


On Mon, May 25, 2020 at 11:42:08AM -0400, Olivier Dion wrote:
> 27:11: W0703: (broad-except)
> 34:15: W0703: (broad-except)
> 42:15: W0703: (broad-except)
> 
> Signed-off-by: Olivier Dion <dion at linutronix.de>
> ---
>  elbepack/commands/add.py | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/elbepack/commands/add.py b/elbepack/commands/add.py
> index 8f666a5f..04b518a0 100644
> --- a/elbepack/commands/add.py
> +++ b/elbepack/commands/add.py
> @@ -24,6 +24,7 @@ def run_command(argv):
>  
>      try:
>          xml = ElbeXML(args[0])
> +    # pylint: disable=broad-except

These broad excepts are not justified.
There are very few places, where these are justified.
(in the soap service methods, where we have to prevent the server from
crashing, and want to repackage any Exception into a proper SOAP
Exceptnion. 

the first 2 occurences here at least print the exception. 
But please just catch ValidationError, and OSError or whatever might
arise. 

This is just a simple command, that will exit anyways.
It might just exit due to an uncaught exception, and we fix that
later on, then.

>      except Exception as e:
>          print("Error reading xml file: %s" % str(e))
>          sys.exit(20)
> @@ -31,12 +32,14 @@ def run_command(argv):
>      for a in args[1:]:
>          try:
>              xml.add_target_package(a)
> +        # pylint: disable=broad-except
>          except Exception as e:
>              print("Error adding package %s: %s" % (a, str(e)))
>              sys.exit(20)
>  
>      try:
>          xml.xml.write(args[0])
> +    # pylint: disable=broad-except
>      except BaseException:
>          print("Unable to write new xml file")
>          sys.exit(20)

this one is really bad.
There might be a typo, and it would exit due to NameError
and print it cant write the file.

This is the worstcase. We have been hunting some of these
and spent a lot more time than necessary.


> -- 
> 2.26.2
> 
> 
> _______________________________________________
> 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