You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by jd...@apache.org on 2023/04/10 20:02:19 UTC

[qpid-python] branch main updated: QPID-8631: modernize the `try: except as:` blocks and `raise`s (#9)

This is an automated email from the ASF dual-hosted git repository.

jdanek pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-python.git


The following commit(s) were added to refs/heads/main by this push:
     new 3746370  QPID-8631: modernize the `try: except as:` blocks and `raise`s (#9)
3746370 is described below

commit 37463700f806ed70561ba9a0d143278599b145c8
Author: Jiri Daněk <jd...@redhat.com>
AuthorDate: Mon Apr 10 22:02:13 2023 +0200

    QPID-8631: modernize the `try: except as:` blocks and `raise`s (#9)
---
 examples/api/drain                           |  2 +-
 examples/api/hello                           |  2 +-
 examples/api/hello_xml                       |  2 +-
 examples/api/server                          |  4 +--
 examples/api/spout                           |  2 +-
 examples/reservations/common.py              |  2 +-
 qpid/compat.py                               |  2 +-
 qpid/connection.py                           |  4 +--
 qpid/connection08.py                         |  4 +--
 qpid/delegates.py                            |  4 +--
 qpid/framer.py                               |  6 ++---
 qpid/managementdata.py                       |  4 +--
 qpid/messaging/driver.py                     | 22 ++++++++--------
 qpid/messaging/endpoints.py                  |  6 ++---
 qpid/messaging/transports.py                 |  4 +--
 qpid/peer.py                                 | 12 ++++-----
 qpid/queue.py                                |  2 +-
 qpid/reference.py                            |  2 +-
 qpid/saslmech/finder.py                      |  2 +-
 qpid/selector.py                             |  8 +++---
 qpid/spec08.py                               |  2 +-
 qpid/testlib.py                              |  8 +++---
 qpid/tests/connection.py                     |  2 +-
 qpid/tests/messaging/__init__.py             |  2 +-
 qpid/tests/messaging/address.py              |  4 +--
 qpid/tests/messaging/endpoints.py            | 34 ++++++++++++-------------
 qpid/tests/messaging/implementation.py       |  2 +-
 qpid/tests/messaging/message.py              |  2 +-
 qpid/tests/messaging/selector.py             |  2 +-
 qpid/tests/parser.py                         |  2 +-
 qpid/util.py                                 |  2 +-
 qpid_tests/broker_0_10/alternate_exchange.py |  8 +++---
 qpid_tests/broker_0_10/dtx.py                | 32 +++++++++++------------
 qpid_tests/broker_0_10/exchange.py           | 22 ++++++++--------
 qpid_tests/broker_0_10/extensions.py         |  4 +--
 qpid_tests/broker_0_10/message.py            | 14 +++++-----
 qpid_tests/broker_0_10/new_api.py            |  2 +-
 qpid_tests/broker_0_10/queue.py              | 38 ++++++++++++++--------------
 qpid_tests/broker_0_8/basic.py               | 10 ++++----
 qpid_tests/broker_0_8/broker.py              |  4 +--
 qpid_tests/broker_0_8/exchange.py            | 10 ++++----
 qpid_tests/broker_0_8/queue.py               | 24 +++++++++---------
 qpid_tests/broker_0_9/queue.py               |  2 +-
 qpid_tests/broker_1_0/general.py             |  2 +-
 setup.py                                     | 20 ++++++---------
 45 files changed, 173 insertions(+), 177 deletions(-)

diff --git a/examples/api/drain b/examples/api/drain
index 5e30153..97f644d 100755
--- a/examples/api/drain
+++ b/examples/api/drain
@@ -89,7 +89,7 @@ try:
       ssn.acknowledge()
     except Empty:
       break
-except ReceiverError, e:
+except ReceiverError as e:
   print e
 except KeyboardInterrupt:
   pass
diff --git a/examples/api/hello b/examples/api/hello
index ad314da..65b0edd 100755
--- a/examples/api/hello
+++ b/examples/api/hello
@@ -46,7 +46,7 @@ try:
   print message.content
   session.acknowledge()
 
-except MessagingError,m:
+except MessagingError as m:
   print m
 
 connection.close()
diff --git a/examples/api/hello_xml b/examples/api/hello_xml
index ab567ec..addeaef 100755
--- a/examples/api/hello_xml
+++ b/examples/api/hello_xml
@@ -71,7 +71,7 @@ try:
   print message.content
   session.acknowledge()
 
-except MessagingError,m:
+except MessagingError as m:
   print m
 
 connection.close()
diff --git a/examples/api/server b/examples/api/server
index 78d812b..23734cb 100755
--- a/examples/api/server
+++ b/examples/api/server
@@ -82,12 +82,12 @@ try:
     try:
       snd = ssn.sender(msg.reply_to)
       snd.send(response)
-    except SendError, e:
+    except SendError as e:
       print e
     if snd is not None:
       snd.close()
     ssn.acknowledge()
-except ReceiverError, e:
+except ReceiverError as e:
   print e
 except KeyboardInterrupt:
   pass
diff --git a/examples/api/spout b/examples/api/spout
index 6584b85..c1b1622 100755
--- a/examples/api/spout
+++ b/examples/api/spout
@@ -125,7 +125,7 @@ try:
     snd.send(msg)
     count += 1
     print msg
-except SendError, e:
+except SendError as e:
   print e
 except KeyboardInterrupt:
   pass
diff --git a/examples/reservations/common.py b/examples/reservations/common.py
index 12f07e1..7602fe1 100644
--- a/examples/reservations/common.py
+++ b/examples/reservations/common.py
@@ -60,7 +60,7 @@ class Dispatcher:
         try:
           snd = session.sender(to)
           snd.send(r)
-        except SendError, e:
+        except SendError as e:
           print e
         finally:
           snd.close()
diff --git a/qpid/compat.py b/qpid/compat.py
index 89e3787..edd604c 100644
--- a/qpid/compat.py
+++ b/qpid/compat.py
@@ -126,7 +126,7 @@ class BaseWaiter:
         try:
           ready, _, _ = select([self], [], [], timeout)
           break
-        except SelectError, e:
+        except SelectError as e:
           if e[0] == errno.EINTR:
             elapsed = time.time() - start
             timeout = timeout - elapsed
diff --git a/qpid/connection.py b/qpid/connection.py
index 2ab870b..4bc9d9d 100644
--- a/qpid/connection.py
+++ b/qpid/connection.py
@@ -182,7 +182,7 @@ class Connection(Framer):
           break
         else:
           continue
-      except socket.error, e:
+      except socket.error as e:
         if self.aborted() or str(e) != "The read operation timed out":
           self.close_code = (None, str(e))
           self.detach_all()
@@ -195,7 +195,7 @@ class Connection(Framer):
       for op in op_dec.read():
         try:
           self.delegate.received(op)
-        except Closed, e:
+        except Closed as e:
           self.close_code = (None, str(e))
           if not self.opened:
             self.failed = True
diff --git a/qpid/connection08.py b/qpid/connection08.py
index 54d7f88..2c4fc91 100644
--- a/qpid/connection08.py
+++ b/qpid/connection08.py
@@ -63,7 +63,7 @@ class SockIO:
     try:
       try:
         self.sock.shutdown(SHUT_RDWR)
-      except socket.error, e:
+      except socket.error as e:
         if (e.errno == errno.ENOTCONN):
           pass
         else:
@@ -131,7 +131,7 @@ def connect(host, port, options = None):
                          certfile=ssl_certfile,
                          ca_certs=ssl_trustfile,
                          cert_reqs=validate)
-    except ImportError, e:
+    except ImportError as e:
       # Python 2.5 and older
       if ssl_verify_hostname:
         log.error("Your version of Python does not support ssl hostname verification. Please upgrade your version of Python.")
diff --git a/qpid/delegates.py b/qpid/delegates.py
index 9018351..e231a85 100644
--- a/qpid/delegates.py
+++ b/qpid/delegates.py
@@ -188,7 +188,7 @@ class Client(Delegate):
     initial = None
     try:
       mech, initial = self.sasl.start(mech_list)
-    except Exception, e:
+    except Exception as e:
       raise Closed(str(e))
     ch.connection_start_ok(client_properties=self.client_properties,
                            mechanism=mech, response=initial)
@@ -197,7 +197,7 @@ class Client(Delegate):
     resp = None
     try:
       resp = self.sasl.step(secure.challenge)
-    except Exception, e:
+    except Exception as e:
       raise Closed(str(e))
     ch.connection_secure_ok(response=resp)
 
diff --git a/qpid/framer.py b/qpid/framer.py
index 08e1722..ff907e9 100644
--- a/qpid/framer.py
+++ b/qpid/framer.py
@@ -53,7 +53,7 @@ class Framer(Packer):
       if self.security_layer_tx:
         try:
           cipher_buf = self.security_layer_tx.encode(self.tx_buf)
-        except SASLError, e:
+        except SASLError as e:
           raise Closed(str(e))
         self._write(cipher_buf)
       else:
@@ -96,14 +96,14 @@ class Framer(Packer):
         if self.security_layer_rx:
           try:
             s = self.security_layer_rx.decode(s)
-          except SASLError, e:
+          except SASLError as e:
             raise Closed(str(e))
       except socket.timeout:
         if self.aborted():
           raise Closed()
         else:
           continue
-      except socket.error, e:
+      except socket.error as e:
         if self.rx_buf != "":
           raise e
         else:
diff --git a/qpid/managementdata.py b/qpid/managementdata.py
index 61cb10c..66a39c6 100644
--- a/qpid/managementdata.py
+++ b/qpid/managementdata.py
@@ -645,7 +645,7 @@ class ManagementData:
         titles = ("Argument", "Type", "Direction", "Unit", "Notes", "Description")
         self.disp.table (caption, titles, rows)
 
-    except Exception,e:
+    except Exception as e:
       pass
     self.lock.release ()
 
@@ -686,7 +686,7 @@ class ManagementData:
 
       self.methodSeq = self.methodSeq + 1
       self.methodsPending[self.methodSeq] = methodName
-    except Exception, e:
+    except Exception as e:
       methodOk = False
     self.lock.release ()
     if methodOk:
diff --git a/qpid/messaging/driver.py b/qpid/messaging/driver.py
index 4692144..7f72e0d 100644
--- a/qpid/messaging/driver.py
+++ b/qpid/messaging/driver.py
@@ -454,7 +454,7 @@ class Driver:
         self._check_retry_ok()
       else:
         self.close_engine()
-    except socket.error, e:
+    except socket.error as e:
       self.close_engine(ConnectionError(text=str(e)))
 
     self.update_status()
@@ -519,7 +519,7 @@ class Driver:
       if n == 0: return
       sent = self.engine.read(n)
       rawlog.debug("SENT[%s]: %r", self.log_id, sent)
-    except socket.error, e:
+    except socket.error as e:
       self.close_engine(e)
       notify = True
 
@@ -551,10 +551,10 @@ class Driver:
           self.connect()
       elif self.engine is not None:
         self.engine.dispatch()
-    except HeartbeatTimeout, e:
+    except HeartbeatTimeout as e:
       log.warn("Heartbeat timeout")
       self.close_engine(e)
-    except ContentError, e:
+    except ContentError as e:
       msg = compat.format_exc()
       self.connection.error = ContentError(text=msg)
     except:
@@ -580,7 +580,7 @@ class Driver:
       else:
         raise ConnectError("no such transport: %s" % self.connection.transport)
       self.schedule()
-    except socket.error, e:
+    except socket.error as e:
       self.close_engine(ConnectError(text=str(e)))
 
 DEFAULT_DISPOSITION = Disposition(None)
@@ -696,7 +696,7 @@ class Engine:
         opslog.debug("RCVD[%s]: %r", self.log_id, op)
         op.dispatch(self)
       self.dispatch()
-    except MessagingError, e:
+    except MessagingError as e:
       self.close(e)
     except:
       self.close(InternalError(text=compat.format_exc()))
@@ -759,7 +759,7 @@ class Engine:
       mechs = start.mechanisms
     try:
       mech, initial = self._sasl.start(" ".join(mechs))
-    except sasl.SASLError, e:
+    except sasl.SASLError as e:
       if "ANONYMOUS" not in mechs and self.connection.username is None:
         _text="Anonymous connections disabled, missing credentials"
       else:
@@ -995,9 +995,9 @@ class Engine:
             xdeclare['auto-delete'] = "True"
           if 'exclusive' not in xdeclare:
             xdeclare['exclusive'] = "True"
-      except address.LexError, e:
+      except address.LexError as e:
         return MalformedAddress(text=str(e))
-      except address.ParseError, e:
+      except address.ParseError as e:
         return MalformedAddress(text=str(e))
 
   def validate_options(self, lnk, dir):
@@ -1369,7 +1369,7 @@ class Engine:
     enc, dec = get_codec(msg.content_type)
     try:
       body = enc(msg.content)
-    except AttributeError, e:
+    except AttributeError as e:
       # convert to non-blocking EncodeError
       raise EncodeError(e)
 
@@ -1428,7 +1428,7 @@ class Engine:
     enc, dec = get_codec(mp.content_type)
     try:
       content = dec(xfr.payload)
-    except Exception, e:
+    except Exception as e:
       raise DecodeError(e)
     msg = Message(content)
     msg.id = mp.message_id
diff --git a/qpid/messaging/endpoints.py b/qpid/messaging/endpoints.py
index d24eb09..a03749d 100644
--- a/qpid/messaging/endpoints.py
+++ b/qpid/messaging/endpoints.py
@@ -671,7 +671,7 @@ class Session(Endpoint):
       self._wakeup()
       try:
         sender._ewait(lambda: sender.linked)
-      except LinkError, e:
+      except LinkError as e:
         sender.close()
         raise e
     return sender
@@ -695,7 +695,7 @@ class Session(Endpoint):
       self._wakeup()
       try:
         receiver._ewait(lambda: receiver.linked)
-      except LinkError, e:
+      except LinkError as e:
         receiver.close()
         raise e
     return receiver
@@ -825,7 +825,7 @@ class Session(Endpoint):
         raise Timeout("commit timed out")
     except TransactionError:
       raise
-    except Exception, e:
+    except Exception as e:
       self.error = TransactionAborted(text="Transaction aborted: %s"%e)
       raise self.error
     if self.aborted:
diff --git a/qpid/messaging/transports.py b/qpid/messaging/transports.py
index c4e7c68..0b2334e 100644
--- a/qpid/messaging/transports.py
+++ b/qpid/messaging/transports.py
@@ -149,7 +149,7 @@ else:
         n = self.tls.write( self.write_retry )
         self.write_retry = None
         return n
-      except SSLError, e:
+      except SSLError as e:
         if self._update_state(e.args[0]):
           # will retry on next invokation
           return 0
@@ -163,7 +163,7 @@ else:
       self._clear_state()
       try:
         return self.tls.read(n)
-      except SSLError, e:
+      except SSLError as e:
         if self._update_state(e.args[0]):
           # will retry later:
           return None
diff --git a/qpid/peer.py b/qpid/peer.py
index 2ff25c0..0eee9cc 100644
--- a/qpid/peer.py
+++ b/qpid/peer.py
@@ -104,12 +104,12 @@ class Peer:
       while True:
         try:
           frame = self.conn.read()
-        except EOF, e:
+        except EOF as e:
           self.work.close("Connection lost")
           break
         ch = self.channel(frame.channel)
         ch.receive(frame, self.work)
-    except VersionError, e:
+    except VersionError as e:
       self.closed(e)
     except:
       self.fatal()
@@ -129,7 +129,7 @@ class Peer:
         try:
           message = self.outgoing.get()
           self.conn.write(message)
-        except socket.error, e:
+        except socket.error as e:
           self.closed(e)
           break
         self.conn.flush()
@@ -150,7 +150,7 @@ class Peer:
           content = None
 
         self.delegate(channel, Message(channel, frame, content))
-    except QueueClosed, e:
+    except QueueClosed as e:
       self.closed(str(e) or "worker closed")
     except:
       self.fatal()
@@ -339,7 +339,7 @@ class Channel:
         return Message(self, resp, read_content(self.responses))
       else:
         return Message(self, resp)
-    except QueueClosed, e:
+    except QueueClosed as e:
       if self._closed:
         raise Closed(self.reason)
       else:
@@ -396,7 +396,7 @@ class Channel:
           raise Closed(self.reason)
         if not completed:
           self.closed("Timed-out waiting for completion of %s" % frame)
-    except QueueClosed, e:
+    except QueueClosed as e:
       if self._closed:
         raise Closed(self.reason)
       else:
diff --git a/qpid/queue.py b/qpid/queue.py
index 100bb0b..af7ee20 100644
--- a/qpid/queue.py
+++ b/qpid/queue.py
@@ -83,7 +83,7 @@ class Queue(BaseQueue):
         o = self.get()
         if o == Queue.STOP: break
         self.listener(o)
-      except Closed, e:
+      except Closed as e:
         if self.exc_listener is not None:
           self.exc_listener(e)
         break
diff --git a/qpid/reference.py b/qpid/reference.py
index 48ecb67..1f1d761 100644
--- a/qpid/reference.py
+++ b/qpid/reference.py
@@ -71,7 +71,7 @@ class Reference:
     def next(self):
         try:
             return self.get_chunk()
-        except Closed, e:
+        except Closed as e:
             raise StopIteration
 
     def __iter__(self):
diff --git a/qpid/saslmech/finder.py b/qpid/saslmech/finder.py
index 1dda9ec..975e79a 100644
--- a/qpid/saslmech/finder.py
+++ b/qpid/saslmech/finder.py
@@ -41,7 +41,7 @@ def get_sasl_mechanism(mechanismNames, username, password, namespace="qpid.saslm
         instances.append(instance)
       else:
         log.debug("SASL mechanism %s unavailable as the prerequistes for this mechanism have not been met", mechanismName)
-    except (ImportError, AttributeError), e:
+    except (ImportError, AttributeError) as e:
       # Unknown mechanism - this is normal if the server supports mechanism that the client does not
       log.debug("Could not load implementation for %s", canonicalName)
       pass
diff --git a/qpid/selector.py b/qpid/selector.py
index a67f0ae..f0f66c8 100644
--- a/qpid/selector.py
+++ b/qpid/selector.py
@@ -151,7 +151,7 @@ class Selector:
               timeout = max(0, wakeup - time.time())
             rd, wr, ex = select(self.reading, self.writing, (), timeout)
             break
-          except SelectError, e:
+          except SelectError as e:
             # Repeat the select call if we were interrupted.
             if e[0] == errno.EINTR:
               continue
@@ -172,7 +172,7 @@ class Selector:
           w = sel.timing()
           if w is not None and now > w:
             sel.timeout()
-    except Exception, e:
+    except Exception as e:
       log.error("qpid.messaging thread died: %s" % e)
       self.exception = SelectorStopped(str(e))
     self.exception = self.exception or self.stopped
@@ -198,11 +198,11 @@ class Selector:
             disable(l, self.exception)
           disable(ssn, self.exception)
         disable(c, self.exception)
-    except Exception, e:
+    except Exception as e:
       log.error("error stopping qpid.messaging (%s)\n%s", self.exception, format_exc())
     try:
       self.waiter.close()
-    except Exception, e:
+    except Exception as e:
       log.error("error stopping qpid.messaging (%s)\n%s", self.exception, format_exc())
 
 # Disable an object to avoid hangs due to forked mutex locks or a stopped selector thread
diff --git a/qpid/spec08.py b/qpid/spec08.py
index b1d0242..3a6f0ce 100644
--- a/qpid/spec08.py
+++ b/qpid/spec08.py
@@ -372,7 +372,7 @@ def load(specfile, *errata):
                        get_docs(nd))
       try:
         spec.constants.add(const)
-      except ValueError, e:
+      except ValueError as e:
         pass
         #print "Warning:", e
 
diff --git a/qpid/testlib.py b/qpid/testlib.py
index 97dff14..4022a7c 100644
--- a/qpid/testlib.py
+++ b/qpid/testlib.py
@@ -93,12 +93,12 @@ class TestBase(unittest.TestCase):
         client = qpid.client.Client(host, port)
         try:
           client.start(username = user, password=password, tune_params=tune_params, client_properties=client_properties, channel_options=channel_options)
-        except qpid.client.Closed, e:
+        except qpid.client.Closed as e:
             if isinstance(e.args[0], VersionError):
                 raise Skipped(e.args[0])
             else:
                 raise e
-        except socket.error, e:
+        except socket.error as e:
             raise Skipped(e)
         return client
 
@@ -230,7 +230,7 @@ class TestBase010(unittest.TestCase):
             default_port = self.DEFAULT_PORT
         try:
             sock = connect(host or url.host, port or url.port or default_port)
-        except socket.error, e:
+        except socket.error as e:
             raise Skipped(e)
         if url.scheme == URL.AMQPS:
             sock = ssl(sock)
@@ -238,7 +238,7 @@ class TestBase010(unittest.TestCase):
                           password=url.password or self.DEFAULT_PASSWORD)
         try:
             conn.start(timeout=10)
-        except VersionError, e:
+        except VersionError as e:
             raise Skipped(e)
         return conn
 
diff --git a/qpid/tests/connection.py b/qpid/tests/connection.py
index 6847285..744a8be 100644
--- a/qpid/tests/connection.py
+++ b/qpid/tests/connection.py
@@ -170,7 +170,7 @@ class ConnectionTest(TestCase):
     try:
       m = echos.get(timeout=10)
       assert False
-    except Closed, e:
+    except Closed as e:
       pass
 
   def testCloseListen(self):
diff --git a/qpid/tests/messaging/__init__.py b/qpid/tests/messaging/__init__.py
index e73c058..dd86d9f 100644
--- a/qpid/tests/messaging/__init__.py
+++ b/qpid/tests/messaging/__init__.py
@@ -47,7 +47,7 @@ class Base(Test):
 
     try:
       self.conn = self.setup_connection()
-    except ConnectError, e:
+    except ConnectError as e:
       raise Skipped(e)
     self.ssn = self.setup_session()
     self.snd = self.setup_sender()
diff --git a/qpid/tests/messaging/address.py b/qpid/tests/messaging/address.py
index aa9562a..a947ee7 100644
--- a/qpid/tests/messaging/address.py
+++ b/qpid/tests/messaging/address.py
@@ -83,9 +83,9 @@ class AddressTests(ParserBase, Test):
     try:
       from subprocess import Popen, PIPE, STDOUT
       po = Popen([parser, mode], stdin=PIPE, stdout=PIPE, stderr=STDOUT)
-    except ImportError, e:
+    except ImportError as e:
       raise Skipped("%s" % e)
-    except OSError, e:
+    except OSError as e:
       raise Skipped("%s: %s" % (e, parser))
     out, _ = po.communicate(input=input)
     return out
diff --git a/qpid/tests/messaging/endpoints.py b/qpid/tests/messaging/endpoints.py
index ce2b418..3c7df7c 100644
--- a/qpid/tests/messaging/endpoints.py
+++ b/qpid/tests/messaging/endpoints.py
@@ -55,7 +55,7 @@ class SetupTests(Base):
       # Specifying port 0 yields a bad address on Windows; port 4 is unassigned
       self.conn = Connection.establish("localhost:4")
       assert False, "connect succeeded"
-    except ConnectError, e:
+    except ConnectError as e:
       assert "refused" in str(e)
 
   def testGetError(self):
@@ -63,7 +63,7 @@ class SetupTests(Base):
     try:
       self.conn.open()
       assert False, "connect succeeded"
-    except ConnectError, e:
+    except ConnectError as e:
       assert self.conn.get_error() == e
 
   def use_fds(self):
@@ -71,7 +71,7 @@ class SetupTests(Base):
     try:
       while True:
         fds.append(os.open(getattr(os, "devnull", "/dev/null"), os.O_RDONLY))
-    except OSError, e:
+    except OSError as e:
       if e.errno != errno.EMFILE:
         raise e
       else:
@@ -103,7 +103,7 @@ class SetupTests(Base):
         conn._lock.release()
         try:
           conn.open()
-        except ConnectError, e:
+        except ConnectError as e:
           pass
     finally:
       while fds:
@@ -738,9 +738,9 @@ class ReceiverTests(Base):
     try:
       msg = self.rcv.fetch(0)
       assert False, "unexpected result: %s" % msg
-    except Empty, e:
+    except Empty as e:
       assert False, "unexpected exception: %s" % e
-    except LinkClosed, e:
+    except LinkClosed as e:
       pass
 
   def testFetchFromClosedReceiver(self):
@@ -761,9 +761,9 @@ class ReceiverTests(Base):
     try:
       msg = self.rcv.fetch()
       assert False, "unexpected result: %s" % msg
-    except Empty, e:
+    except Empty as e:
       assert False, "unexpected exception: %s" % e
-    except LinkClosed, e:
+    except LinkClosed as e:
       pass
     t.join()
 
@@ -971,13 +971,13 @@ class AddressTests(Base):
     try:
       self.ssn.sender("test-bad-options-snd; %s" % options)
       assert False
-    except InvalidOption, e:
+    except InvalidOption as e:
       assert "error in options: %s" % error == str(e), e
 
     try:
       self.ssn.receiver("test-bad-options-rcv; %s" % options)
       assert False
-    except InvalidOption, e:
+    except InvalidOption as e:
       assert "error in options: %s" % error == str(e), e
 
   def testIllegalKey(self):
@@ -1054,7 +1054,7 @@ class AddressTests(Base):
     snd.close()
     try:
       self.ssn.sender("test-delete")
-    except NotFound, e:
+    except NotFound as e:
       assert "no such queue" in str(e)
 
   def testDeleteByReceiver(self):
@@ -1068,7 +1068,7 @@ class AddressTests(Base):
     try:
       self.ssn.receiver("test-delete")
       assert False
-    except NotFound, e:
+    except NotFound as e:
       assert "no such queue" in str(e)
 
   def testDeleteSpecial(self):
@@ -1077,7 +1077,7 @@ class AddressTests(Base):
     try:
       snd.close()
       assert False, "successfully deleted amq.topic"
-    except SessionError, e:
+    except SessionError as e:
       assert e.code == 530
     # XXX: need to figure out close after error
     self.conn._remove_session(self.ssn)
@@ -1230,9 +1230,9 @@ test-link-bindings-queue; {
     try:
       snd = self.ssn.sender("amq.topic; {assert: always, node: {type: queue}}")
       assert 0, "assertion failed to trigger"
-    except AssertionFailed, e:
+    except AssertionFailed as e:
       pass
-    except NotFound, e:  # queue named amp.topic not found
+    except NotFound as e:  # queue named amp.topic not found
       pass
 
   def testAssert2(self):
@@ -1254,14 +1254,14 @@ class AddressErrorTests(Base):
     try:
       self.ssn.sender(addr, durable=self.durable())
       assert False, "sender creation succeeded"
-    except exc, e:
+    except exc as e:
       assert check(e), "unexpected error: %s" % compat.format_exc(e)
 
   def receiverErrorTest(self, addr, exc, check=lambda e: True):
     try:
       self.ssn.receiver(addr)
       assert False, "receiver creation succeeded"
-    except exc, e:
+    except exc as e:
       assert check(e), "unexpected error: %s" % compat.format_exc(e)
 
   def testNoneTarget(self):
diff --git a/qpid/tests/messaging/implementation.py b/qpid/tests/messaging/implementation.py
index fce60c6..553d06b 100644
--- a/qpid/tests/messaging/implementation.py
+++ b/qpid/tests/messaging/implementation.py
@@ -21,7 +21,7 @@ if 'QPID_USE_SWIG_CLIENT' in os.environ and os.environ['QPID_USE_SWIG_CLIENT']:
   try:
     from qpid_messaging import *
     from qpid.datatypes import uuid4
-  except ImportError, e:
+  except ImportError as e:
     print "Swigged client not found. Falling back to pure bindings, %s\n" % e
     from qpid.messaging import *
 else:
diff --git a/qpid/tests/messaging/message.py b/qpid/tests/messaging/message.py
index bfdd2c7..76bb103 100644
--- a/qpid/tests/messaging/message.py
+++ b/qpid/tests/messaging/message.py
@@ -179,7 +179,7 @@ class MessageEchoTests(Base):
       self.snd.send(msg)
       self.rcv.fetch(0)
       assert False, "Exception not raised on mismatched content/content_type"
-    except Exception, e:
+    except Exception as e:
       pass
 
   def testRecoverAfterException(self):
diff --git a/qpid/tests/messaging/selector.py b/qpid/tests/messaging/selector.py
index 6a40faf..3332894 100644
--- a/qpid/tests/messaging/selector.py
+++ b/qpid/tests/messaging/selector.py
@@ -85,7 +85,7 @@ class SelectorTests(TestCase):
         self.assertRaises(SelectorStopped, c.session) # But can't use parent connection
         s.send("child")
         os._exit(0)
-      except Exception, e:
+      except Exception as e:
         print >>sys.stderr, "test child process error: %s" % e
         os.exit(1)
       finally:
diff --git a/qpid/tests/parser.py b/qpid/tests/parser.py
index a4865cc..d6e1067 100644
--- a/qpid/tests/parser.py
+++ b/qpid/tests/parser.py
@@ -33,5 +33,5 @@ class ParserBase:
     try:
       p = self.do_parse(addr)
       assert False, "invalid address parsed: %s" % p
-    except ParseError, e:
+    except ParseError as e:
       assert error == str(e), "expected %r, got %r" % (error, str(e))
diff --git a/qpid/util.py b/qpid/util.py
index b17f13e..285d8b5 100644
--- a/qpid/util.py
+++ b/qpid/util.py
@@ -76,7 +76,7 @@ def connect(host, port):
     try:
       sock.connect(sa)
       break
-    except socket.error, msg:
+    except socket.error as msg:
       sock.close()
   else:
     # If we got here then we couldn't connect (yet)
diff --git a/qpid_tests/broker_0_10/alternate_exchange.py b/qpid_tests/broker_0_10/alternate_exchange.py
index 2e2d5de..4d522c8 100644
--- a/qpid_tests/broker_0_10/alternate_exchange.py
+++ b/qpid_tests/broker_0_10/alternate_exchange.py
@@ -110,7 +110,7 @@ class AlternateExchangeTests(TestBase010):
         try:
             session2.exchange_delete(exchange="alternate")
             self.fail("Expected deletion of in-use alternate-exchange to fail")
-        except SessionException, e:
+        except SessionException as e:
             session = self.session
             session.queue_delete(queue="q")
             session.exchange_delete(exchange="alternate")
@@ -130,7 +130,7 @@ class AlternateExchangeTests(TestBase010):
         try:
             session.exchange_delete(exchange="alternate")
             self.fail("Expected deletion of in-use alternate-exchange to fail")
-        except SessionException, e:
+        except SessionException as e:
             session = self.session
             session.exchange_delete(exchange="e")
             session.exchange_delete(exchange="alternate")
@@ -150,7 +150,7 @@ class AlternateExchangeTests(TestBase010):
             # attempt to change the alternate on an already existing exchange
             session.exchange_declare(exchange="onealternate", type="fanout", alternate_exchange="alt2")
             self.fail("Expected changing an alternate on an existing exchange to fail")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(530, e.args[0].error_code)
         session = self.conn.session("alternate", 2)
         session.exchange_delete(exchange="onealternate")
@@ -170,7 +170,7 @@ class AlternateExchangeTests(TestBase010):
             # attempt to add an alternate on an already existing exchange
             session.exchange_declare(exchange="noalternate", type="fanout", alternate_exchange="alt1")
             self.fail("Expected adding an alternate on an existing exchange to fail")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(530, e.args[0].error_code)
         session = self.conn.session("alternate", 2)
         session.exchange_delete(exchange="noalternate")
diff --git a/qpid_tests/broker_0_10/dtx.py b/qpid_tests/broker_0_10/dtx.py
index a9619bc..b2cbe8a 100644
--- a/qpid_tests/broker_0_10/dtx.py
+++ b/qpid_tests/broker_0_10/dtx.py
@@ -162,7 +162,7 @@ class DtxTests(TestBase010):
             session.dtx_end(xid=tx)
             session.dtx_rollback(xid=tx)
             self.fail("Session not selected for use with dtx, expected exception!")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(503, e.args[0].error_code)
 
     def test_start_already_known(self):
@@ -187,7 +187,7 @@ class DtxTests(TestBase010):
         failed = False
         try:
             session2.dtx_start(xid=tx)
-        except SessionException, e:
+        except SessionException as e:
             failed = True
             error = e
 
@@ -233,7 +233,7 @@ class DtxTests(TestBase010):
             session.dtx_end(xid=tx)
             session.dtx_rollback(xid=tx)
             self.fail("Join and resume both set, expected exception!")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(503, e.args[0].error_code)
 
     def test_start_join(self):
@@ -353,7 +353,7 @@ class DtxTests(TestBase010):
         try:
             session.dtx_end(xid=tx, suspend=True, fail=True)
             self.fail("Suspend and fail both set, expected exception!")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(503, e.args[0].error_code)
 
         #cleanup
@@ -376,7 +376,7 @@ class DtxTests(TestBase010):
         try:
             session.dtx_end(xid=tx)
             self.fail("Attempted to end association with unknown xid, expected exception!")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(409, e.args[0].error_code)
 
     def test_end(self):
@@ -431,7 +431,7 @@ class DtxTests(TestBase010):
         failed = False
         try:
             tester.dtx_commit(xid=tx, one_phase=True)
-        except SessionException, e:
+        except SessionException as e:
             failed = True
             error = e
 
@@ -459,7 +459,7 @@ class DtxTests(TestBase010):
         failed = False
         try:
             tester.dtx_commit(xid=tx, one_phase=False)
-        except SessionException, e:
+        except SessionException as e:
             failed = True
             error = e
 
@@ -486,7 +486,7 @@ class DtxTests(TestBase010):
         failed = False
         try:
             tester.dtx_commit(xid=tx, one_phase=False)
-        except SessionException, e:
+        except SessionException as e:
             failed = True
             error = e
 
@@ -514,7 +514,7 @@ class DtxTests(TestBase010):
         failed = False
         try:
             tester.dtx_rollback(xid=tx)
-        except SessionException, e:
+        except SessionException as e:
             failed = True
             error = e
 
@@ -543,7 +543,7 @@ class DtxTests(TestBase010):
         failed = False
         try:
             tester.dtx_prepare(xid=tx)
-        except SessionException, e:
+        except SessionException as e:
             failed = True
             error = e
 
@@ -641,7 +641,7 @@ class DtxTests(TestBase010):
         session.dtx_start(xid=tx)
         try:
             session.dtx_set_timeout(xid=tx, timeout=3601)
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(542, e.args[0].error_code)
 
 
@@ -690,35 +690,35 @@ class DtxTests(TestBase010):
         session = self.session
         try:
             session.dtx_start(resume=True)
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(503, e.args[0].error_code)
 
     def test_prepare_unknown(self):
         session = self.session
         try:
             session.dtx_prepare(xid=self.xid("unknown"))
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(404, e.args[0].error_code)
 
     def test_commit_unknown(self):
         session = self.session
         try:
             session.dtx_commit(xid=self.xid("unknown"))
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(404, e.args[0].error_code)
 
     def test_rollback_unknown(self):
         session = self.session
         try:
             session.dtx_rollback(xid=self.xid("unknown"))
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(404, e.args[0].error_code)
 
     def test_get_timeout_unknown(self):
         session = self.session
         try:
             session.dtx_get_timeout(xid=self.xid("unknown"))
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(404, e.args[0].error_code)
 
     def xid(self, txid):
diff --git a/qpid_tests/broker_0_10/exchange.py b/qpid_tests/broker_0_10/exchange.py
index 916f9d8..350b96f 100644
--- a/qpid_tests/broker_0_10/exchange.py
+++ b/qpid_tests/broker_0_10/exchange.py
@@ -299,7 +299,7 @@ class DeclareMethodExchangeFieldReservedRuleTests(TestHelper):
         try:
             self.session.exchange_declare(exchange=reservedString, type=exchangeType)
             self.fail("Expected not allowed error (530) for exchanges starting with \"" + reservedString + "\".")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(e.args[0].error_code, 530)
         # connection closed, reopen it
         self.tearDown()
@@ -307,7 +307,7 @@ class DeclareMethodExchangeFieldReservedRuleTests(TestHelper):
         try:
             self.session.exchange_declare(exchange=reservedString + "abc123", type=exchangeType)
             self.fail("Expected not allowed error (530) for exchanges starting with \"" + reservedString + "\".")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(e.args[0].error_code, 530)
         # connection closed, reopen it
         self.tearDown()
@@ -363,7 +363,7 @@ class DeclareMethodPassiveFieldNotFoundRuleTests(TestHelper):
         try:
             self.session.exchange_declare(exchange="humpty_dumpty", passive=True)
             self.fail("Expected 404 for passive declaration of unknown exchange.")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(404, e.args[0].error_code)
 
 
@@ -472,7 +472,7 @@ class MiscellaneousErrorsTests(TestHelper):
         try:
             self.session.exchange_declare(exchange="test_type_not_known_exchange", type="invalid_type")
             self.fail("Expected 404 for declaration of unknown exchange type.")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(404, e.args[0].error_code)
 
     def testDifferentDeclaredType(self):
@@ -481,7 +481,7 @@ class MiscellaneousErrorsTests(TestHelper):
             session = self.conn.session("alternate", 2)
             session.exchange_declare(exchange="test_different_declared_type_exchange", type="topic")
             self.fail("Expected 530 for redeclaration of exchange with different type.")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(530, e.args[0].error_code)
 
     def testReservedExchangeRedeclaredSameType(self):
@@ -491,7 +491,7 @@ class MiscellaneousErrorsTests(TestHelper):
         try:
             self.exchange_declare(exchange="amq.direct", type="topic")
             self.fail("Expected 530 for redeclaration of exchange with different type.")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(530, e.args[0].error_code)
 
     def testDefaultAccessBind(self):
@@ -499,7 +499,7 @@ class MiscellaneousErrorsTests(TestHelper):
             self.session.queue_declare(queue="my-queue", auto_delete=True, exclusive=True)
             self.session.exchange_bind(exchange="", queue="my-queue", binding_key="another-key")
             self.fail("Expected 542 (invalid-argument) code for bind to default exchange.")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(542, e.args[0].error_code)
 
     def testDefaultAccessUnbind(self):
@@ -507,14 +507,14 @@ class MiscellaneousErrorsTests(TestHelper):
             self.session.queue_declare(queue="my-queue", auto_delete=True, exclusive=True)
             self.session.exchange_unbind(exchange="", queue="my-queue", binding_key="my-queue")
             self.fail("Expected 542 (invalid-argument) code for unbind from default exchange.")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(542, e.args[0].error_code)
 
     def testDefaultAccessDelete(self):
         try:
             self.session.exchange_delete(exchange="")
             self.fail("Expected 542 (invalid-argument) code for delete of default exchange.")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(542, e.args[0].error_code)
 
 class ExchangeTests(TestHelper):
@@ -523,7 +523,7 @@ class ExchangeTests(TestHelper):
         try:
             self.session.exchange_bind(queue="q", exchange="amq.match", arguments={"name":"fred" , "age":3} )
             self.fail("Expected failure for missing x-match arg.")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(541, e.args[0].error_code)
 
 class AutodeleteTests(TestHelper, StandardExchangeVerifier):
@@ -533,7 +533,7 @@ class AutodeleteTests(TestHelper, StandardExchangeVerifier):
             s.exchange_declare(exchange=e, passive=True)
             s.exchange_delete(exchange=e)
             self.fail("Expected failure for passive declare of %s" % e)
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(404, e.args[0].error_code)
 
 
diff --git a/qpid_tests/broker_0_10/extensions.py b/qpid_tests/broker_0_10/extensions.py
index 50c0aa3..944a869 100644
--- a/qpid_tests/broker_0_10/extensions.py
+++ b/qpid_tests/broker_0_10/extensions.py
@@ -43,7 +43,7 @@ class ExtensionTests(TestBase010):
         try:
             self.session.queue_declare(queue=name, arguments=args)
             self.session.queue_delete(queue=name) # cleanup
-        except SessionException, e:
+        except SessionException as e:
             self.fail("declare with valid policy args failed: %s" % (args))
             self.session = self.conn.session("replacement", 2)
 
@@ -56,7 +56,7 @@ class ExtensionTests(TestBase010):
                 self.session.queue_declare(queue=name, arguments=args)
                 self.session.queue_delete(queue=name) # cleanup
                 self.fail("declare with invalid policy args suceeded: %s (iteration %d)" % (args, i))
-            except SessionException, e:
+            except SessionException as e:
                 self.session = self.conn.session(str(uuid4()))
 
     def test_policy_max_size_as_valid_string(self):
diff --git a/qpid_tests/broker_0_10/message.py b/qpid_tests/broker_0_10/message.py
index 4814168..42ab071 100644
--- a/qpid_tests/broker_0_10/message.py
+++ b/qpid_tests/broker_0_10/message.py
@@ -166,7 +166,7 @@ class MessageTests(TestBase010):
         try:
             session.message_subscribe(destination="second", queue="test-queue-2")
             self.fail("Expected consume request to fail due to previous exclusive consumer")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(405, e.args[0].error_code)
 
     def test_consume_exclusive2(self):
@@ -179,7 +179,7 @@ class MessageTests(TestBase010):
         try:
             session.message_subscribe(destination="second", queue="test-queue-2", exclusive=True)
             self.fail("Expected exclusive consume request to fail due to previous consumer")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(405, e.args[0].error_code)
 
     def test_consume_queue_not_found(self):
@@ -191,7 +191,7 @@ class MessageTests(TestBase010):
             #queue specified but doesn't exist:
             session.message_subscribe(queue="invalid-queue", destination="a")
             self.fail("Expected failure when consuming from non-existent queue")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(404, e.args[0].error_code)
 
     def test_consume_queue_not_specified(self):
@@ -200,7 +200,7 @@ class MessageTests(TestBase010):
             #queue not specified and none previously declared for channel:
             session.message_subscribe(destination="a")
             self.fail("Expected failure when consuming from unspecified queue")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(531, e.args[0].error_code)
 
     def test_consume_unique_consumers(self):
@@ -216,7 +216,7 @@ class MessageTests(TestBase010):
         try:
             session.message_subscribe(destination="first", queue="test-queue-3")
             self.fail("Expected consume request to fail due to non-unique tag")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(530, e.args[0].error_code)
 
     def test_cancel(self):
@@ -249,14 +249,14 @@ class MessageTests(TestBase010):
         try:
             session.message_cancel(destination="my-consumer")
             self.fail("Expected 404 for recancellation of subscription.")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(404, e.args[0].error_code)
 
         session = self.conn.session("alternate-session", timeout=10)
         try:
             session.message_cancel(destination="this-never-existed")
             self.fail("Expected 404 for cancellation of unknown subscription.")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(404, e.args[0].error_code)
 
 
diff --git a/qpid_tests/broker_0_10/new_api.py b/qpid_tests/broker_0_10/new_api.py
index 4e94395..a2d724f 100644
--- a/qpid_tests/broker_0_10/new_api.py
+++ b/qpid_tests/broker_0_10/new_api.py
@@ -54,7 +54,7 @@ class GeneralTests(Base):
         try:
             ssn.receiver("does-not-exist")
             self.fail("Expected non-existent node to cause NotFound exception")
-        except NotFound, e: None
+        except NotFound as e: None
 
     def test_qpid_3481_acquired_to_alt_exchange(self):
         """
diff --git a/qpid_tests/broker_0_10/queue.py b/qpid_tests/broker_0_10/queue.py
index 132bd7b..68fe854 100644
--- a/qpid_tests/broker_0_10/queue.py
+++ b/qpid_tests/broker_0_10/queue.py
@@ -65,7 +65,7 @@ class QueueTests(TestBase010):
             #queue specified but doesn't exist:
             session.queue_purge(queue="invalid-queue")            
             self.fail("Expected failure when purging non-existent queue")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(404, e.args[0].error_code) #not-found
 
     def test_purge_empty_name(self):        
@@ -78,7 +78,7 @@ class QueueTests(TestBase010):
             #queue not specified and none previously declared for channel:
             session.queue_purge()
             self.fail("Expected failure when purging unspecified queue")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(531, e.args[0].error_code) #illegal-argument
 
     def test_declare_exclusive(self):
@@ -97,7 +97,7 @@ class QueueTests(TestBase010):
             #other connection should not be allowed to declare this:
             s2.queue_declare(queue="exclusive-queue", exclusive=True, auto_delete=True)
             self.fail("Expected second exclusive queue_declare to raise a channel exception")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(405, e.args[0].error_code)
 
         s3 = self.conn.session("subscriber")
@@ -105,7 +105,7 @@ class QueueTests(TestBase010):
             #other connection should not be allowed to declare this:
             s3.message_subscribe(queue="exclusive-queue")
             self.fail("Expected message_subscribe on an exclusive queue to raise a channel exception")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(405, e.args[0].error_code)
 
         s4 = self.conn.session("deleter")
@@ -113,7 +113,7 @@ class QueueTests(TestBase010):
             #other connection should not be allowed to declare this:
             s4.queue_delete(queue="exclusive-queue")
             self.fail("Expected queue_delete on an exclusive queue to raise a channel exception")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(405, e.args[0].error_code)
 
         s5 = self.conn.session("binder")
@@ -121,7 +121,7 @@ class QueueTests(TestBase010):
             #other connection should not be allowed to declare this:
             s5.exchange_bind(exchange="amq.direct", queue="exclusive-queue", binding_key="abc")
             self.fail("Expected exchange_bind on an exclusive queue to raise an exception")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(405, e.args[0].error_code)
 
         s6 = self.conn.session("unbinder")
@@ -129,7 +129,7 @@ class QueueTests(TestBase010):
             #other connection should not be allowed to declare this:
             s6.exchange_unbind(exchange="amq.fanout", queue="exclusive-queue")
             self.fail("Expected exchange_unbind on an exclusive queue to raise an exception")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(405, e.args[0].error_code)
 
     def test_declare_exclusive_alreadyinuse(self):
@@ -148,7 +148,7 @@ class QueueTests(TestBase010):
             #other connection should not be allowed to declare this:
             s2.queue_declare(queue="a-queue", exclusive=True, auto_delete=True)
             self.fail("Expected request for exclusivity to fail")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(405, e.args[0].error_code)
 
     def test_declare_passive(self):
@@ -175,7 +175,7 @@ class QueueTests(TestBase010):
       try:
         s1.queue_declare(queue="passive-queue-not-found", passive=True)
         self.fail("Expected passive declaration of non-existent queue to raise a channel exception")
-      except SessionException, e:
+      except SessionException as e:
         self.assertEquals(404, e.args[0].error_code) #not-found
 
 
@@ -198,7 +198,7 @@ class QueueTests(TestBase010):
         try:
           s2.queue_declare(queue="passive-queue-nonexc", exclusive=True, passive=True)
           self.fail("Expected exclusive passive declaration of existing queue to raise a channel exception")
-        except SessionException, e:
+        except SessionException as e:
           self.assertEquals(405, e.args[0].error_code) # resource locked
 
     def test_bind(self):
@@ -218,7 +218,7 @@ class QueueTests(TestBase010):
         try:
             session.exchange_bind(queue="queue-1", exchange="an-invalid-exchange", binding_key="key1")
             self.fail("Expected bind to non-existant exchange to fail")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(404, e.args[0].error_code)
 
 
@@ -228,7 +228,7 @@ class QueueTests(TestBase010):
         try:
             session.exchange_bind(queue="queue-2", exchange="amq.direct", binding_key="key1")
             self.fail("Expected bind of non-existant queue to fail")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(404, e.args[0].error_code)
 
     def test_unbind_direct(self):
@@ -312,7 +312,7 @@ class QueueTests(TestBase010):
         try:
             session.queue_declare(queue="delete-me", passive=True)
             self.fail("Queue has not been deleted")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(404, e.args[0].error_code)
 
     def test_delete_queue_exists(self):
@@ -324,7 +324,7 @@ class QueueTests(TestBase010):
         try:
             session.queue_delete(queue="i-dont-exist", if_empty=True)
             self.fail("Expected delete of non-existant queue to fail")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(404, e.args[0].error_code)
 
         
@@ -344,7 +344,7 @@ class QueueTests(TestBase010):
         try:
             session.queue_delete(queue="delete-me-2", if_empty=True)
             self.fail("Expected delete if_empty to fail for non-empty queue")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(406, e.args[0].error_code)
 
         #need new session now:    
@@ -367,7 +367,7 @@ class QueueTests(TestBase010):
         try:
             session.queue_declare(queue="delete-me-2", passive=True)
             self.fail("Queue has not been deleted")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(404, e.args[0].error_code)
         
     def test_delete_ifunused(self):
@@ -388,7 +388,7 @@ class QueueTests(TestBase010):
         try:
             session2.queue_delete(queue="delete-me-3", if_unused=True)
             self.fail("Expected delete if_unused to fail for queue with existing consumer")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(406, e.args[0].error_code)
 
         session.message_cancel(destination="consumer_tag")    
@@ -397,7 +397,7 @@ class QueueTests(TestBase010):
         try:
             session.queue_declare(queue="delete-me-3", passive=True)
             self.fail("Queue has not been deleted")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(404, e.args[0].error_code)
 
 
@@ -430,7 +430,7 @@ class QueueTests(TestBase010):
         try:
             session.queue_declare(queue="auto-delete-me", passive=True)
             self.fail("Expected queue to have been deleted")
-        except SessionException, e:
+        except SessionException as e:
             self.assertEquals(404, e.args[0].error_code)
 
 
diff --git a/qpid_tests/broker_0_8/basic.py b/qpid_tests/broker_0_8/basic.py
index 9457897..04b364c 100644
--- a/qpid_tests/broker_0_8/basic.py
+++ b/qpid_tests/broker_0_8/basic.py
@@ -64,7 +64,7 @@ class BasicTests(TestBase):
         try:
             channel.basic_consume(consumer_tag="second", queue="test-queue-2")
             self.fail("Expected consume request to fail due to previous exclusive consumer")
-        except Closed, e:
+        except Closed as e:
             self.assertChannelException(403, e.args[0])
 
         #open new channel and cleanup last consumer:    
@@ -76,7 +76,7 @@ class BasicTests(TestBase):
         try:
             channel.basic_consume(consumer_tag="second", queue="test-queue-2", exclusive=True)
             self.fail("Expected exclusive consume request to fail due to previous consumer")
-        except Closed, e:
+        except Closed as e:
             self.assertChannelException(403, e.args[0])
 
     def test_reconnect_to_durable_subscription(self):
@@ -133,7 +133,7 @@ class BasicTests(TestBase):
             #queue specified but doesn't exist:
             channel.basic_consume(queue="invalid-queue")
             self.fail("Expected failure when consuming from non-existent queue")
-        except Closed, e:
+        except Closed as e:
             self.assertChannelException(404, e.args[0])
 
         channel = self.client.channel(2)
@@ -142,7 +142,7 @@ class BasicTests(TestBase):
             #queue not specified and none previously declared for channel:
             channel.basic_consume(queue="")
             self.fail("Expected failure when consuming from unspecified queue")
-        except Closed, e:
+        except Closed as e:
             self.assertConnectionException(530, e.args[0])
 
     def test_consume_unique_consumers(self):
@@ -158,7 +158,7 @@ class BasicTests(TestBase):
         try:
             channel.basic_consume(consumer_tag="first", queue="test-queue-3")
             self.fail("Expected consume request to fail due to non-unique tag")
-        except Closed, e:
+        except Closed as e:
             self.assertConnectionException(530, e.args[0])
 
     def test_cancel(self):
diff --git a/qpid_tests/broker_0_8/broker.py b/qpid_tests/broker_0_8/broker.py
index 1948a13..b281c72 100644
--- a/qpid_tests/broker_0_8/broker.py
+++ b/qpid_tests/broker_0_8/broker.py
@@ -89,7 +89,7 @@ class BrokerTests(TestBase):
         try:
             channel.queue_declare(exclusive=True)
             self.fail("Expected error on queue_declare for invalid channel")
-        except Closed, e:
+        except Closed as e:
             self.assertConnectionException(504, e.args[0])
         
     def test_closed_channel(self):
@@ -99,7 +99,7 @@ class BrokerTests(TestBase):
         try:
             channel.queue_declare(exclusive=True)
             self.fail("Expected error on queue_declare for closed channel")
-        except Closed, e:
+        except Closed as e:
             self.assertConnectionException(504, e.args[0])
 
     def test_channel_flow(self):
diff --git a/qpid_tests/broker_0_8/exchange.py b/qpid_tests/broker_0_8/exchange.py
index 8d610a7..3c7b493 100644
--- a/qpid_tests/broker_0_8/exchange.py
+++ b/qpid_tests/broker_0_8/exchange.py
@@ -221,7 +221,7 @@ class DeclareMethodPassiveFieldNotFoundRuleTests(TestBase):
         try:
             self.channel.exchange_declare(exchange="humpty_dumpty", passive=True)
             self.fail("Expected 404 for passive declaration of unknown exchange.")
-        except Closed, e:
+        except Closed as e:
             self.assertChannelException(404, e.args[0])
 
 
@@ -313,7 +313,7 @@ class MiscellaneousErrorsTests(TestBase):
         try:
             self.channel.exchange_declare(exchange="test_type_not_known_exchange", type="invalid_type")
             self.fail("Expected 503 for declaration of unknown exchange type.")
-        except Closed, e:
+        except Closed as e:
             self.assertConnectionException(503, e.args[0])
 
     def testDifferentDeclaredType(self):
@@ -321,7 +321,7 @@ class MiscellaneousErrorsTests(TestBase):
         try:
             self.channel.exchange_declare(exchange="test_different_declared_type_exchange", type="topic")
             self.fail("Expected 530 for redeclaration of exchange with different type.")
-        except Closed, e:
+        except Closed as e:
             self.assertConnectionException(530, e.args[0])
         #cleanup    
         other = self.connect()
@@ -337,13 +337,13 @@ class MiscellaneousErrorsTests(TestBase):
         try:
             self.channel.exchange_declare(exchange="amq.direct", type="topic", passive=False)
             self.fail("Expected 530 for redeclaration of exchange with different type.")
-        except Closed, e:
+        except Closed as e:
             self.assertConnectionException(530, e.args[0])
 
     def testReservedExchangeNameDisallowed(self):
         try:
             self.channel.exchange_declare(exchange="amq.myexch", type="direct", passive=False)
             self.fail("Expected 530 for redeclaration of exchange with different type.")
-        except Closed, e:
+        except Closed as e:
             self.assertConnectionException(530, e.args[0])
 
diff --git a/qpid_tests/broker_0_8/queue.py b/qpid_tests/broker_0_8/queue.py
index 32e087b..a354d06 100644
--- a/qpid_tests/broker_0_8/queue.py
+++ b/qpid_tests/broker_0_8/queue.py
@@ -61,7 +61,7 @@ class QueueTests(TestBase):
             #queue specified but doesn't exist:
             channel.queue_purge(queue="invalid-queue")
             self.fail("Expected failure when purging non-existent queue")
-        except Closed, e:
+        except Closed as e:
             self.assertChannelException(404, e.args[0])
 
         channel = self.client.channel(3)
@@ -70,7 +70,7 @@ class QueueTests(TestBase):
             #queue not specified and none previously declared for channel:
             channel.queue_purge()
             self.fail("Expected failure when purging unspecified queue")
-        except Closed, e:
+        except Closed as e:
             self.assertConnectionException(530, e.args[0])
 
         #cleanup    
@@ -96,7 +96,7 @@ class QueueTests(TestBase):
             #other connection should not be allowed to declare this:
             c2.queue_declare(queue="exclusive-queue", exclusive="True")
             self.fail("Expected second exclusive queue_declare to raise a channel exception")
-        except Closed, e:
+        except Closed as e:
             self.assertChannelException(405, e.args[0])
 
 
@@ -112,7 +112,7 @@ class QueueTests(TestBase):
             #other connection should not be allowed to declare this:
             channel.queue_declare(queue="passive-queue-2", passive="True")
             self.fail("Expected passive declaration of non-existant queue to raise a channel exception")
-        except Closed, e:
+        except Closed as e:
             self.assertChannelException(404, e.args[0])
 
 
@@ -136,7 +136,7 @@ class QueueTests(TestBase):
         try:
             channel.queue_bind(queue="queue-1", exchange="an-invalid-exchange", routing_key="key1")
             self.fail("Expected bind to non-existant exchange to fail")
-        except Closed, e:
+        except Closed as e:
             self.assertChannelException(404, e.args[0])
 
         #need to reopen a channel:    
@@ -147,7 +147,7 @@ class QueueTests(TestBase):
         try:
             channel.queue_bind(queue="queue-2", exchange="amq.direct", routing_key="key1")
             self.fail("Expected bind of non-existant queue to fail")
-        except Closed, e:
+        except Closed as e:
             self.assertChannelException(404, e.args[0])
 
 
@@ -168,7 +168,7 @@ class QueueTests(TestBase):
         try:
             channel.queue_declare(queue="delete-me", passive="True")
             self.fail("Queue has not been deleted")
-        except Closed, e:
+        except Closed as e:
             self.assertChannelException(404, e.args[0])
 
         #check attempted deletion of non-existant queue is handled correctly:    
@@ -177,7 +177,7 @@ class QueueTests(TestBase):
         try:
             channel.queue_delete(queue="i-dont-exist", if_empty="True")
             self.fail("Expected delete of non-existant queue to fail")
-        except Closed, e:
+        except Closed as e:
             self.assertChannelException(404, e.args[0])
 
         
@@ -197,7 +197,7 @@ class QueueTests(TestBase):
         try:
             channel.queue_delete(queue="delete-me-2", if_empty="True")
             self.fail("Expected delete if_empty to fail for non-empty queue")
-        except Closed, e:
+        except Closed as e:
             self.assertChannelException(406, e.args[0])
 
         #need new channel now:    
@@ -218,7 +218,7 @@ class QueueTests(TestBase):
         try:
             channel.queue_declare(queue="delete-me-2", passive="True")
             self.fail("Queue has not been deleted")
-        except Closed, e:
+        except Closed as e:
             self.assertChannelException(404, e.args[0])
         
     def test_delete_ifunused(self):
@@ -239,7 +239,7 @@ class QueueTests(TestBase):
         try:
             channel2.queue_delete(queue="delete-me-3", if_unused="True")
             self.fail("Expected delete if_unused to fail for queue with existing consumer")
-        except Closed, e:
+        except Closed as e:
             self.assertChannelException(406, e.args[0])
 
 
@@ -249,7 +249,7 @@ class QueueTests(TestBase):
         try:
             channel.queue_declare(queue="delete-me-3", passive="True")
             self.fail("Queue has not been deleted")
-        except Closed, e:
+        except Closed as e:
             self.assertChannelException(404, e.args[0])
 
 
diff --git a/qpid_tests/broker_0_9/queue.py b/qpid_tests/broker_0_9/queue.py
index 674895c..8d6ae1c 100644
--- a/qpid_tests/broker_0_9/queue.py
+++ b/qpid_tests/broker_0_9/queue.py
@@ -109,7 +109,7 @@ class QueueTests(TestBase):
         try:
             channel.queue_declare(queue="auto-delete-me", passive=True)
             self.fail("Expected queue to have been deleted")
-        except Closed, e:
+        except Closed as e:
             self.assertChannelException(404, e.args[0])
 
     def test_flow_control(self):
diff --git a/qpid_tests/broker_1_0/general.py b/qpid_tests/broker_1_0/general.py
index a5b9779..9433e86 100644
--- a/qpid_tests/broker_1_0/general.py
+++ b/qpid_tests/broker_1_0/general.py
@@ -59,7 +59,7 @@ class GeneralTests (VersionTest):
             assert msg.content == expected.content
             try:
                 assert msg.properties.get('x-amqp-delivery-count') == 0, (msg.properties.get('x-amqp-delivery-count'))
-            except KeyError, e: None #default is 0
+            except KeyError as e: None #default is 0
             self.ssn.acknowledge(msg)
         rcv.close()
 
diff --git a/setup.py b/setup.py
index e3b13cb..eef6735 100755
--- a/setup.py
+++ b/setup.py
@@ -39,8 +39,7 @@ class preprocessor:
     name, actor = self.actor(src, dst)
     if actor:
       if not os.path.isfile(src):
-        raise DistutilsFileError, \
-            "can't copy '%s': doesn't exist or not a regular file" % src
+        raise DistutilsFileError("can't copy '%s': doesn't exist or not a regular file" % src)
 
       if os.path.isdir(dst):
         dir = dst
@@ -61,22 +60,19 @@ class preprocessor:
       else:
         try:
           fsrc = open(src, 'rb')
-        except os.error, (errno, errstr):
-          raise DistutilsFileError, \
-              "could not open '%s': %s" % (src, errstr)
+        except os.error as (errno, errstr):
+          raise DistutilsFileError("could not open '%s': %s" % (src, errstr))
 
         if os.path.exists(dst):
           try:
             os.unlink(dst)
-          except os.error, (errno, errstr):
-            raise DistutilsFileError, \
-                "could not delete '%s': %s" % (dst, errstr)
+          except os.error as (errno, errstr):
+            raise DistutilsFileError("could not delete '%s': %s" % (dst, errstr))
 
         try:
           fdst = open(dst, 'wb')
-        except os.error, (errno, errstr):
-          raise DistutilsFileError, \
-              "could not create '%s': %s" % (dst, errstr)
+        except os.error as (errno, errstr):
+          raise DistutilsFileError("could not create '%s': %s" % (dst, errstr))
 
         try:
           fdst.write(actor(fsrc.read()))
@@ -129,7 +125,7 @@ class build_doc(Command):
     try:
       from epydoc.docbuilder import build_doc_index
       from epydoc.docwriter.html import HTMLWriter
-    except ImportError, e:
+    except ImportError as e:
       log.warn('%s -- skipping build_doc', e)
       return
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org