Catch specific exception rather than anything

The bare "except" also catches exceptions like "NameError" and
"SystemExit", which we really should not catch.  In scour.py, use the
most specific exception (NotFoundErr) and in the tests just catch any
"regular" exception.

Reported by flake8.

Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
Niels Thykier 2018-02-17 09:15:45 +00:00 committed by Eduard Braun
parent f3d8936b5e
commit 843706be39
2 changed files with 6 additions and 6 deletions

View file

@ -56,7 +56,7 @@ import re
import sys
import time
import xml.dom.minidom
from xml.dom import Node
from xml.dom import Node, NotFoundErr
from collections import namedtuple
from decimal import Context, Decimal, InvalidOperation, getcontext
@ -3619,7 +3619,7 @@ def scourXmlFile(filename, options=None):
for node in all_nodes:
try:
node.setIdAttribute('id')
except:
except NotFoundErr:
pass
return doc