New style exception arguments

pull/7/head
Ferry Boender 9 years ago
parent 3759575e8e
commit acb0333b0a
  1. 2
      src/formdefinition.py
  2. 6
      src/scriptform.py
  3. 4
      src/webserver.py

@ -84,7 +84,7 @@ class FormDefinition(object):
value = self._field_validate(field_name, form_values) value = self._field_validate(field_name, form_values)
if value is not None: if value is not None:
values[field_name] = value values[field_name] = value
except ValidationError, err: except ValidationError as err:
errors.setdefault(field_name, []).append(str(err)) errors.setdefault(field_name, []).append(str(err))
return (errors, values) return (errors, values)

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# Scriptform roughly works like this: # Scriptform roughly works like this:
@ -234,14 +234,14 @@ def main(): # pragma: no cover
elif options.action_stop: elif options.action_stop:
daemon.stop() daemon.stop()
sys.exit(0) sys.exit(0)
except socket.error, err: except socket.error as err:
log.exception(err) log.exception(err)
sys.stderr.write("Cannot bind to port {}: {}\n".format( sys.stderr.write("Cannot bind to port {}: {}\n".format(
options.port, options.port,
str(err) str(err)
)) ))
sys.exit(2) sys.exit(2)
except Exception, err: except Exception as err:
log.exception(err) log.exception(err)
raise raise

@ -95,7 +95,7 @@ class RequestHandler(BaseHTTPRequestHandler):
else: else:
raise HTTPError(404, "Not found") raise HTTPError(404, "Not found")
method_cb(**params) method_cb(**params)
except HTTPError, err: except HTTPError as err:
# HTTP erors are generally thrown by the webapp on purpose. Send # HTTP erors are generally thrown by the webapp on purpose. Send
# error to the browser. # error to the browser.
if err.status_code not in (401, ): if err.status_code not in (401, ):
@ -108,7 +108,7 @@ class RequestHandler(BaseHTTPRequestHandler):
err.msg)) err.msg))
self.wfile.flush() self.wfile.flush()
return False return False
except Exception, err: except Exception as err:
self.scriptform.log.exception(err) self.scriptform.log.exception(err)
self.send_error(500, "Internal server error") self.send_error(500, "Internal server error")
raise raise

Loading…
Cancel
Save