summaryrefslogtreecommitdiff
path: root/wsgitools
diff options
context:
space:
mode:
Diffstat (limited to 'wsgitools')
-rw-r--r--wsgitools/authentication.py2
-rw-r--r--wsgitools/digest.py13
-rw-r--r--wsgitools/scgi/asynchronous.py2
-rw-r--r--wsgitools/scgi/forkpool.py4
4 files changed, 11 insertions, 10 deletions
diff --git a/wsgitools/authentication.py b/wsgitools/authentication.py
index 6f5d07b..963dc00 100644
--- a/wsgitools/authentication.py
+++ b/wsgitools/authentication.py
@@ -64,7 +64,7 @@ class AuthenticationMiddleware:
raise AuthenticationRequired(
"authorization method not implemented: %r" % method)
result = self.authenticate(rest, environ)
- except AuthenticationRequired, exc:
+ except AuthenticationRequired as exc:
return self.authorization_required(environ, start_response, exc)
assert isinstance(result, dict)
assert "user" in result
diff --git a/wsgitools/digest.py b/wsgitools/digest.py
index 085047f..4b5f8fb 100644
--- a/wsgitools/digest.py
+++ b/wsgitools/digest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python2.5
"""
This module contains an C{AuthDigestMiddleware} for authenticating HTTP
requests using the method described in RFC2617. The credentials are to be
@@ -259,7 +258,7 @@ class UpdatingHtdigestTokenGenerator(HtdigestTokenGenerator):
# modifications.
try:
self.statcache = os.stat(htdigestfile)
- except OSError, err:
+ except OSError as err:
raise IOError(str(err))
HtdigestTokenGenerator.__init__(self, realm, htdigestfile,
ignoreparseerrors)
@@ -276,7 +275,9 @@ class UpdatingHtdigestTokenGenerator(HtdigestTokenGenerator):
if self.statcache != statcache:
try:
self.readhtdigest(self.htdigestfile, self.ignoreparseerrors)
- except (IOError, ValueError):
+ except IOError:
+ return None
+ except ValueError:
return None
return HtdigestTokenGenerator.__call__(self, user, algo)
@@ -724,7 +725,7 @@ class AuthDigestMiddleware(AuthenticationMiddleware):
try:
nonce = credentials["nonce"]
credresponse = credentials["response"]
- except KeyError, err:
+ except KeyError as err:
raise ProtocolViolation("%s missing in credentials" %
err.args[0])
noncecount = 1
@@ -765,7 +766,7 @@ class AuthDigestMiddleware(AuthenticationMiddleware):
username = credentials["username"]
algo = credentials["algorithm"]
uri = credentials["uri"]
- except KeyError, err:
+ except KeyError as err:
raise ProtocolViolation("%s missing in credentials" % err.args[0])
try:
dig = [credentials["nonce"]]
@@ -778,7 +779,7 @@ class AuthDigestMiddleware(AuthenticationMiddleware):
try:
dig.append(credentials["nc"])
dig.append(credentials["cnonce"])
- except KeyError, err:
+ except KeyError as err:
raise ProtocolViolation(
"missing %s in credentials with qop=auth" % err.args[0])
dig.append(qop)
diff --git a/wsgitools/scgi/asynchronous.py b/wsgitools/scgi/asynchronous.py
index 386e1d0..1dee283 100644
--- a/wsgitools/scgi/asynchronous.py
+++ b/wsgitools/scgi/asynchronous.py
@@ -262,7 +262,7 @@ class SCGIServer(asyncore.dispatcher):
"""asyncore interface"""
try:
ret = self.accept()
- except socket.error, err:
+ except socket.error as err:
# See http://bugs.python.org/issue6706
if err.args[0] not in (errno.ECONNABORTED, errno.EAGAIN):
raise
diff --git a/wsgitools/scgi/forkpool.py b/wsgitools/scgi/forkpool.py
index cdd50f0..1bf0c6f 100644
--- a/wsgitools/scgi/forkpool.py
+++ b/wsgitools/scgi/forkpool.py
@@ -41,7 +41,7 @@ class SocketFileWrapper:
return ""
try:
data = self.sock.recv(toread)
- except socket.error, why:
+ except socket.error as why:
if why[0] in (errno.ECONNRESET, errno.ENOTCONN, errno.ESHUTDOWN):
data = ""
else:
@@ -250,7 +250,7 @@ class SCGIServer:
self.spawnworker()
try:
rs, _, _ = select.select(self.workers.keys(), [], [])
- except select.error, e:
+ except select.error as e:
if e[0] != errno.EINTR:
raise
rs = []