Commit f7d4453b authored by Raul Tambre's avatar Raul Tambre Committed by Commit Bot

//build: Use Python 3 style exception statements

Conversion was done automatically using "2to3 -w -f except".

This is backwards compatible with Python 2.
There are no intended behavioural changes.

Bug: 941669
Change-Id: I00e5acf46cdf0999c5e2f6e8e85e55e2fc611eca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1815871
Commit-Queue: Raul Tambre <raul@tambre.ee>
Auto-Submit: Raul Tambre <raul@tambre.ee>
Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700375}
parent 3743d539
......@@ -301,7 +301,7 @@ class JSONResultsGeneratorBase(object):
"JSON upload failed, %d: '%s'", response.code, response.read())
else:
_log.error('JSON upload failed; no response returned')
except Exception, err: # pylint: disable=broad-except
except Exception as err: # pylint: disable=broad-except
_log.error('Upload failed: %s', err)
return
......@@ -385,12 +385,12 @@ class JSONResultsGeneratorBase(object):
# FIXME: We should talk to the network via a Host object.
results_file = urllib2.urlopen(results_file_url)
old_results = results_file.read()
except urllib2.HTTPError, http_error:
except urllib2.HTTPError as http_error:
# A non-4xx status code means the bot is hosed for some reason
# and we can't grab the results.json file off of it.
if http_error.code < 400 and http_error.code >= 500:
error = http_error
except urllib2.URLError, url_error:
except urllib2.URLError as url_error:
error = url_error
# pylint: enable=redefined-variable-type
......
......@@ -96,7 +96,7 @@ def DoMain(argv):
def main(argv):
try:
result = DoMain(argv[1:])
except WrongNumberOfArgumentsException, e:
except WrongNumberOfArgumentsException as e:
print(e, file=sys.stderr)
return 1
if result:
......
......@@ -60,7 +60,7 @@ def Main(argv):
stderr=subprocess.STDOUT)
else:
os.symlink(s, t)
except OSError, e:
except OSError as e:
if e.errno == errno.EEXIST and options.force:
if os.path.isdir(t):
shutil.rmtree(t, ignore_errors=True)
......@@ -69,7 +69,7 @@ def Main(argv):
os.symlink(s, t)
else:
raise
except subprocess.CalledProcessError, e:
except subprocess.CalledProcessError as e:
# Since subprocess.check_output does not return an easily checked error
# number, in the 'force' case always assume it is 'file already exists'
# and retry.
......
......@@ -366,7 +366,7 @@ class SpawningServerRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
"""Stops the test server instance."""
try:
port = int(params['port'][0])
except ValueError, KeyError:
except ValueError:
port = None
if port == None or port <= 0:
self._SendResponse(400, 'Invalid request.', {}, 'port must be specified')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment