From nobody Sat Feb 7 09:37:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570625962; cv=none; d=zoho.com; s=zohoarc; b=bitOsh+X/73Fee6t+Fg9kHwZeWSzO9l2pBsc9ipV7iFzQuzL5lHO9xP8SfBBg3TSWIPuP7sOMjjxuzyonPJiJrStmyNlARjpQg9xHJozgPYK2PMBPJGxae49dvtbLG9W8oDofDYOxvjvxXIwYe9mk91qo4nomod5HYrjyxNr6fo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570625962; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1xjYVjwSNGLQB6zYsQqCMOoSAo/oQCHWJ7ROdXfS5Bs=; b=F6gorEoscDQXBR2ZU8L5KNANdHM9LQwEnxtNweR9egY8zkzg7Ylt5e2kL9RemvcKFQs+qURL6EZtGcTvIM0lZgfsjGNydbwOOmhQDpUC+aXzD/V9JH57N3o9jwpcJjwHD8coX+3aVJPP2aMc3gxgZy8EKsa7MeYEzmRcDVvXY7A= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570625962714287.19629313132384; Wed, 9 Oct 2019 05:59:22 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CDAB811A23; Wed, 9 Oct 2019 12:59:20 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A66086061E; Wed, 9 Oct 2019 12:59:20 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5EEDE18037C9; Wed, 9 Oct 2019 12:59:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x99CxAqW002979 for ; Wed, 9 Oct 2019 08:59:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 699A15DA8C; Wed, 9 Oct 2019 12:59:10 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDF7C5DAAD; Wed, 9 Oct 2019 12:59:04 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 9 Oct 2019 13:58:40 +0100 Message-Id: <20191009125844.18202-7-berrange@redhat.com> In-Reply-To: <20191009125844.18202-1-berrange@redhat.com> References: <20191009125844.18202-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/10] python: avoid bare 'except:' clause X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 09 Oct 2019 12:59:21 +0000 (UTC) Exception catching statements should always match on a class name, the most specific one possible. Rather than analyse the code to look at what the most specific one is, this just uses the base Exception class. docs/apibuild.py:255:9: E722 do not use bare 'except' except: ^ docs/apibuild.py:279:9: E722 do not use bare 'except' except: ^ ...more... Signed-off-by: Daniel P. Berrang=C3=A9 --- build-aux/syntax-check.mk | 2 -- docs/apibuild.py | 38 +++++++++++++++++++------------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index b138220b30..c66183c1b0 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -883,14 +883,12 @@ FLAKE8_INDENTATION =3D E114,E115,E116,E121,E125,E126,= E127,E128,E129,E131 FLAKE8_WHITESPACE =3D E211,E221,E222,E225,E226,E231,E261 FLAKE8_BLANK_LINES =3D E301,E302,E303,E305 FLAKE8_LINE_LENGTH =3D E501 -FLAKE8_STATEMENTS =3D E722 FLAKE8_WARNINGS =3D W504 =20 FLAKE8_IGNORE =3D $(FLAKE8_INDENTATION),$\ $(FLAKE8_WHITESPACE),$\ $(FLAKE8_BLANK_LINES),$\ $(FLAKE8_LINE_LENGTH),$\ - $(FLAKE8_STATEMENTS),$\ $(FLAKE8_WARNINGS) \ $(NULL) =20 diff --git a/docs/apibuild.py b/docs/apibuild.py index b3ef462565..86163c20b1 100755 --- a/docs/apibuild.py +++ b/docs/apibuild.py @@ -252,7 +252,7 @@ class index: try: d =3D self.identifiers[name] d.update(header, module, type, lineno, info, extra, conditiona= ls) - except: + except Exception: d =3D identifier(name, header, module, type, lineno, info, ext= ra, conditionals) self.identifiers[name] =3D d @@ -276,7 +276,7 @@ class index: try: d =3D self.identifiers[name] d.update(header, module, type, lineno, info, extra, conditiona= ls) - except: + except Exception: d =3D identifier(name, header, module, type, lineno, info, ext= ra, conditionals) self.identifiers[name] =3D d @@ -784,7 +784,7 @@ class CParser: arg, desc =3D prefix.split(':', 1) desc =3D desc.strip() arg =3D arg.strip() - except: + except Exception: if not quiet: self.warning("Misformatted macro comment for %s" % nam= e) self.warning(" problem with '%s'" % lines[0]) @@ -865,7 +865,7 @@ class CParser: arg, desc =3D prefix.split(':', 1) desc =3D desc.strip() arg =3D arg.strip() - except: + except Exception: if not quiet: self.warning("Misformatted function comment for %s" % = name) self.warning(" problem with '%s'" % lines[0]) @@ -908,7 +908,7 @@ class CParser: if len(line) >=3D 6 and line[0:7] =3D=3D "Returns": try: line =3D line.split(' ', 1)[1] - except: + except Exception: line =3D "" retdesc =3D line.strip() del lines[0] @@ -976,7 +976,7 @@ class CParser: token =3D self.lexer.token() try: name =3D name.split('(') [0] - except: + except Exception: pass =20 # skip hidden macros @@ -1016,7 +1016,7 @@ class CParser: self.defines.append(apstr) if apstr.find('ENABLED') !=3D -1: self.conditionals.append("defined(%s)" % apstr) - except: + except Exception: pass elif name =3D=3D "#ifndef": apstr =3D self.lexer.tokens[0][1] @@ -1024,7 +1024,7 @@ class CParser: self.defines.append(apstr) if apstr.find('ENABLED') !=3D -1: self.conditionals.append("!defined(%s)" % apstr) - except: + except Exception: pass elif name =3D=3D "#if": apstr =3D "" @@ -1036,7 +1036,7 @@ class CParser: self.defines.append(apstr) if apstr.find('ENABLED') !=3D -1: self.conditionals.append(apstr) - except: + except Exception: pass elif name =3D=3D "#else": if self.conditionals !=3D [] and \ @@ -1338,7 +1338,7 @@ class CParser: else: try: value =3D "%d" % (int(value) + 1) - except: + except Exception: self.warning("Failed to compute value of enum %s" = % name) value =3D "" if token[0] =3D=3D "sep" and token[1] =3D=3D ",": @@ -1797,7 +1797,7 @@ class CParser: try: if not CParser.long_legacy_functions[name][0]: raise Exception() - except: + except Exception: self.error(("function '%s' is not allowed to return long, " "use long long instead") % name) =20 @@ -1806,7 +1806,7 @@ class CParser: try: if param[1] not in CParser.long_legacy_functions[name]= [1]: raise Exception() - except: + except Exception: self.error(("function '%s' is not allowed to take long= " "parameter '%s', use long long instead") % (name, param[1])) @@ -1826,7 +1826,7 @@ class CParser: try: if field[1] not in CParser.long_legacy_struct_fields[n= ame]: raise Exception() - except: + except Exception: self.error(("struct '%s' is not allowed to contain lon= g " "field '%s', use long long instead") % (name, field[1])) @@ -2101,7 +2101,7 @@ class docBuilder: try: val =3D eval(info[0]) valhex =3D hex(val) - except: + except Exception: val =3D info[0] output.write(" value=3D'%s'" % (val)) =20 @@ -2181,7 +2181,7 @@ class docBuilder: self.serialize_union(output, field, desc) else: output.write(" \n" % (field[1], field[0], desc)) - except: + except Exception: self.warning("Failed to serialize struct %s" % name) output.write(" \n") else: @@ -2196,7 +2196,7 @@ class docBuilder: output.write(" \n") else: output.write("/>\n") - except: + except Exception: output.write("/>\n") =20 def serialize_variable(self, output, name): @@ -2251,7 +2251,7 @@ class docBuilder: else: output.write(" \n" % (param[1], param[0], escape(param[2]))) self.indexString(name, param[2]) - except: + except Exception: print("Exception:", sys.exc_info()[1], file=3Dsys.stderr) self.warning("Failed to save function %s info: %s" % (name, re= pr(id.info))) output.write(" \n" % (id.type)) @@ -2331,7 +2331,7 @@ class docBuilder: funcs[param[0]].append(name) else: funcs[param[0]] =3D [name] - except: + except Exception: pass typ =3D sorted(funcs.keys()) for type in typ: @@ -2359,7 +2359,7 @@ class docBuilder: funcs[ret[0]].append(name) else: funcs[ret[0]] =3D [name] - except: + except Exception: pass typ =3D sorted(funcs.keys()) for type in typ: --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list