Skip to content

Commit

Permalink
No more bare except blocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbasta committed Sep 20, 2012
1 parent 10c0a62 commit d7ee7bb
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion validator/opensearch.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def detect_opensearch(err, package, listed=False):
# Parse the file. # Parse the file.
try: try:
srch_prov = parse(package) srch_prov = parse(package)
except: except Exception:
err.error( err.error(
err_id=("opensearch", err_id=("opensearch",
"detect_opensearch", "detect_opensearch",
Expand Down
2 changes: 1 addition & 1 deletion validator/testcases/content.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def _process_file(err, xpi_package, name, file_data, name_lower,
try: try:
sub_xpi = XPIManager(package, mode="r", name=name, sub_xpi = XPIManager(package, mode="r", name=name,
subpackage=is_subpackage) subpackage=is_subpackage)
except: except Exception:
err.error(("testcases_content", err.error(("testcases_content",
"test_packed_packages", "test_packed_packages",
"jar_subpackage_corrupt"), "jar_subpackage_corrupt"),
Expand Down
2 changes: 1 addition & 1 deletion validator/testcases/javascript/call_definitions.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def wrap(wrapper, arguments, traverser):
", ".join(map(str, params))) ", ".join(map(str, params)))
try: try:
output = func(*params) output = func(*params)
except: except (ValueError, TypeError):
# If we cannot compute output, just return nothing. # If we cannot compute output, just return nothing.
output = None output = None


Expand Down
2 changes: 1 addition & 1 deletion validator/testcases/javascript/spidermonkey.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def _get_tree(code, shell):
try: try:
temp.close() temp.close()
os.unlink(temp.name) os.unlink(temp.name)
except: except IOError:
pass pass


if not data: if not data:
Expand Down
2 changes: 1 addition & 1 deletion validator/testcases/l10n/dtd.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _parse(self, data):
line += "\n" line += "\n"
try: try:
parser.feed(line) parser.feed(line)
except: except Exception:
parser = DTDXMLParser() parser = DTDXMLParser()
else: else:
if parser.out_buffer: if parser.out_buffer:
Expand Down
2 changes: 1 addition & 1 deletion validator/testcases/markup/csstester.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_css_file(err, filename, data, line_start=1):
filename=filename, filename=filename,
line_start=line_start - 1, line_start=line_start - 1,
context=context) context=context)
except: # pragma: no cover except Exception: # pragma: no cover
# This happens because tokenize is a generator. # This happens because tokenize is a generator.
# Bravo, Mr. Bond, Bravo. # Bravo, Mr. Bond, Bravo.
err.warning(("testcases_markup_csstester", err.warning(("testcases_markup_csstester",
Expand Down
2 changes: 1 addition & 1 deletion validator/testcases/markup/markuptester.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def _feed_parser(self, line):
try: try:
line = line.decode("ascii", "ignore") line = line.decode("ascii", "ignore")
self.feed(line + "\n") self.feed(line + "\n")
except: except Exception:
raise exc_instance, None, traceback raise exc_instance, None, traceback


except Exception as inst: except Exception as inst:
Expand Down
4 changes: 2 additions & 2 deletions validator/unicodehelper.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def decode(data):
# Try straight UTF-8 # Try straight UTF-8
try: try:
return unicode(data, "utf-8") return unicode(data, "utf-8")
except: except UnicodeDecodeError:
pass pass


# Test for latin_1, because it can be matched as UTF-16 # Test for latin_1, because it can be matched as UTF-16
Expand All @@ -40,7 +40,7 @@ def decode(data):
if all(ord(c) < 256 for c in data): if all(ord(c) < 256 for c in data):
try: try:
return unicode(data, "latin_1") return unicode(data, "latin_1")
except: except UnicodeDecodeError:
pass pass


# Test for various common encodings. # Test for various common encodings.
Expand Down

0 comments on commit d7ee7bb

Please sign in to comment.