summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2012-06-28 16:12:52 +0200
committerHelmut Grohne <helmut@subdivi.de>2012-06-28 16:12:52 +0200
commitee5abb0e0b24b4e1ac31412a279a40e166482fce (patch)
tree011e53de9cccec90864052c9bb6506f6b6ac31c9
parent17dbb95ded62f9789a60a913c008ce2217f6d1a5 (diff)
downloadwsgitools-ee5abb0e0b24b4e1ac31412a279a40e166482fce.tar.gz
drop support for python2.5, use except ... as ...
-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 = []