Skip to content

Commit

Permalink
git cl upload: stop using deprecated except syntax
Browse files Browse the repository at this point in the history
The newer form works with python2 and python3.

Review-Url: https://codereview.chromium.org/2076643002
  • Loading branch information
vapier authored and Commit bot committed Jun 16, 2016
1 parent 62d045c commit 2cc483c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions third_party/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ def GetEmail(prompt):
last_email = last_email_file.readline().strip("\n")
last_email_file.close()
prompt += " [%s]" % last_email
except IOError, e:
except IOError as e:
pass
email = raw_input(prompt + ": ").strip()
if email:
try:
last_email_file = open(last_email_file_name, "w")
last_email_file.write(email)
last_email_file.close()
except IOError, e:
except IOError as e:
pass
else:
email = last_email
Expand Down Expand Up @@ -288,7 +288,7 @@ def _GetAuthToken(self, email, password, internal=False):
response_dict = dict(x.split("=")
for x in response_body.split("\n") if x)
return response_dict["Auth"]
except urllib2.HTTPError, e:
except urllib2.HTTPError as e:
if e.code == 403:
body = e.read()
response_dict = dict(x.split("=", 1) for x in body.split("\n") if x)
Expand All @@ -313,7 +313,7 @@ def _GetAuthCookie(self, auth_token):
(self.host, urllib.urlencode(args)))
try:
response = self.opener.open(req)
except urllib2.HTTPError, e:
except urllib2.HTTPError as e:
response = e
if (response.code != 302 or
response.info()["location"] != continue_location):
Expand Down Expand Up @@ -357,7 +357,7 @@ def _Authenticate(self, force_refresh):
}
auth_token = self._GetAuthToken(credentials[0], credentials[1],
internal=True)
except ClientLoginError, exc:
except ClientLoginError as exc:
e = exc
if e:
print('', file=sys.stderr)
Expand Down Expand Up @@ -450,7 +450,7 @@ def Send(self, request_path, payload=None,
response = f.read()
f.close()
return response
except urllib2.HTTPError, e:
except urllib2.HTTPError as e:
if tries > 3:
raise
elif e.code in (302, 401, 403):
Expand Down Expand Up @@ -999,7 +999,7 @@ def UploadFile(filename, file_id, content, is_binary, status, is_base):
[("data", filename, content)])
try:
response_body = rpc_server.Send(url, body, content_type=ctype)
except urllib2.HTTPError, e:
except urllib2.HTTPError as e:
response_body = ("Failed to upload file for %s. Got %d status code." %
(filename, e.code))

Expand Down Expand Up @@ -2069,7 +2069,7 @@ def UploadFile(filename, data):

try:
response_body = rpc_server.Send(url, body, content_type=ctype)
except urllib2.HTTPError, e:
except urllib2.HTTPError as e:
response_body = ("Failed to upload patch for %s. Got %d status code." %
(filename, e.code))

Expand Down Expand Up @@ -2133,8 +2133,8 @@ def RunDetectCommand(vcs_type, command):
out, returncode = RunShellWithReturnCode(command)
if returncode == 0:
return (vcs_type, out.strip())
except OSError, (errcode, message):
if errcode != errno.ENOENT: # command not found code
except OSError as e:
if e.errno != errno.ENOENT: # command not found code
raise

# Mercurial has a command to get the base directory of a repository
Expand Down

0 comments on commit 2cc483c

Please sign in to comment.