qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject [13/41] qpid-proton git commit: PROTON-1848: Removed some python < 2.6 code - Also fixed some PEP-8 errors
Date Wed, 04 Jul 2018 15:57:45 GMT
PROTON-1848: Removed some python < 2.6 code
- Also fixed some PEP-8 errors


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/81eac9e3
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/81eac9e3
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/81eac9e3

Branch: refs/heads/go1
Commit: 81eac9e3f604e84be6366330eba52806b943ba95
Parents: d9d9e1b
Author: Andrew Stitcher <astitcher@apache.org>
Authored: Wed Jun 6 16:23:06 2018 +0100
Committer: Andrew Stitcher <astitcher@apache.org>
Committed: Wed Jun 6 16:27:30 2018 +0100

----------------------------------------------------------------------
 python/proton/handlers.py           | 51 ++++++++++++++++----------------
 tests/python/proton_tests/common.py | 26 ++--------------
 2 files changed, 28 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/81eac9e3/python/proton/handlers.py
----------------------------------------------------------------------
diff --git a/python/proton/handlers.py b/python/proton/handlers.py
index 1e61f44..15e31a0 100644
--- a/python/proton/handlers.py
+++ b/python/proton/handlers.py
@@ -66,21 +66,21 @@ class OutgoingMessageHandler(Handler):
         Called when the sender link has credit and messages can
         therefore be transferred.
         """
-        if self.delegate != None:
+        if self.delegate is not None:
             dispatch(self.delegate, 'on_sendable', event)
 
     def on_accepted(self, event):
         """
         Called when the remote peer accepts an outgoing message.
         """
-        if self.delegate != None:
+        if self.delegate is not None:
             dispatch(self.delegate, 'on_accepted', event)
 
     def on_rejected(self, event):
         """
         Called when the remote peer rejects an outgoing message.
         """
-        if self.delegate != None:
+        if self.delegate is not None:
             dispatch(self.delegate, 'on_rejected', event)
 
     def on_released(self, event):
@@ -89,7 +89,7 @@ class OutgoingMessageHandler(Handler):
         that this may be in response to either the RELEASE or MODIFIED
         state as defined by the AMQP specification.
         """
-        if self.delegate != None:
+        if self.delegate is not None:
             dispatch(self.delegate, 'on_released', event)
 
     def on_settled(self, event):
@@ -98,7 +98,7 @@ class OutgoingMessageHandler(Handler):
         message. This is the point at which it should never be
         retransmitted.
         """
-        if self.delegate != None:
+        if self.delegate is not None:
             dispatch(self.delegate, 'on_settled', event)
 
 
@@ -203,15 +203,15 @@ class IncomingMessageHandler(Handler, Acking):
         explicitly accepting it, the ``delivery`` should be used, also
         obtainable via a property on the event.
         """
-        if self.delegate != None:
+        if self.delegate is not None:
             dispatch(self.delegate, 'on_message', event)
 
     def on_settled(self, event):
-        if self.delegate != None:
+        if self.delegate is not None:
             dispatch(self.delegate, 'on_settled', event)
 
     def on_aborted(self, event):
-        if self.delegate != None:
+        if self.delegate is not None:
             dispatch(self.delegate, 'on_aborted', event)
 
 
@@ -324,75 +324,75 @@ class EndpointStateHandler(Handler):
             event.link.open()
 
     def on_connection_opened(self, event):
-        if self.delegate != None:
+        if self.delegate is not None:
             dispatch(self.delegate, 'on_connection_opened', event)
 
     def on_session_opened(self, event):
-        if self.delegate != None:
+        if self.delegate is not None:
             dispatch(self.delegate, 'on_session_opened', event)
 
     def on_link_opened(self, event):
-        if self.delegate != None:
+        if self.delegate is not None:
             dispatch(self.delegate, 'on_link_opened', event)
 
     def on_connection_opening(self, event):
-        if self.delegate != None:
+        if self.delegate is not None:
             dispatch(self.delegate, 'on_connection_opening', event)
 
     def on_session_opening(self, event):
-        if self.delegate != None:
+        if self.delegate is not None:
             dispatch(self.delegate, 'on_session_opening', event)
 
     def on_link_opening(self, event):
-        if self.delegate != None:
+        if self.delegate is not None:
             dispatch(self.delegate, 'on_link_opening', event)
 
     def on_connection_error(self, event):
-        if self.delegate != None:
+        if self.delegate is not None:
             dispatch(self.delegate, 'on_connection_error', event)
         else:
             self.log_error(event.connection, "connection")
 
     def on_session_error(self, event):
-        if self.delegate != None:
+        if self.delegate is not None:
             dispatch(self.delegate, 'on_session_error', event)
         else:
             self.log_error(event.session, "session")
             event.connection.close()
 
     def on_link_error(self, event):
-        if self.delegate != None:
+        if self.delegate is not None:
             dispatch(self.delegate, 'on_link_error', event)
         else:
             self.log_error(event.link, "link")
             event.connection.close()
 
     def on_connection_closed(self, event):
-        if self.delegate != None:
+        if self.delegate is not None:
             dispatch(self.delegate, 'on_connection_closed', event)
 
     def on_session_closed(self, event):
-        if self.delegate != None:
+        if self.delegate is not None:
             dispatch(self.delegate, 'on_session_closed', event)
 
     def on_link_closed(self, event):
-        if self.delegate != None:
+        if self.delegate is not None:
             dispatch(self.delegate, 'on_link_closed', event)
 
     def on_connection_closing(self, event):
-        if self.delegate != None:
+        if self.delegate is not None:
             dispatch(self.delegate, 'on_connection_closing', event)
         elif self.peer_close_is_error:
             self.on_connection_error(event)
 
     def on_session_closing(self, event):
-        if self.delegate != None:
+        if self.delegate is not None:
             dispatch(self.delegate, 'on_session_closing', event)
         elif self.peer_close_is_error:
             self.on_session_error(event)
 
     def on_link_closing(self, event):
-        if self.delegate != None:
+        if self.delegate is not None:
             dispatch(self.delegate, 'on_link_closing', event)
         elif self.peer_close_is_error:
             self.on_link_error(event)
@@ -401,7 +401,7 @@ class EndpointStateHandler(Handler):
         self.on_transport_closed(event)
 
     def on_transport_closed(self, event):
-        if self.delegate != None and event.connection and self.is_local_open(event.connection):
+        if self.delegate is not None and event.connection and self.is_local_open(event.connection):
             dispatch(self.delegate, 'on_disconnected', event)
 
 
@@ -430,7 +430,8 @@ class MessagingHandler(Handler, Acking):
         if event.transport.condition:
             if event.transport.condition.info:
                 log.error("%s: %s: %s" % (
-                event.transport.condition.name, event.transport.condition.description, event.transport.condition.info))
+                    event.transport.condition.name, event.transport.condition.description,
+                    event.transport.condition.info))
             else:
                 log.error("%s: %s" % (event.transport.condition.name, event.transport.condition.description))
             if event.transport.condition.name in self.fatal_conditions:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/81eac9e3/tests/python/proton_tests/common.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/common.py b/tests/python/proton_tests/common.py
index 016ffbb..ed65e2f 100644
--- a/tests/python/proton_tests/common.py
+++ b/tests/python/proton_tests/common.py
@@ -31,34 +31,12 @@ from random import randint
 from threading import Thread
 from socket import socket, AF_INET, SOCK_STREAM
 from subprocess import Popen,PIPE,STDOUT
-import sys, os, string, subprocess
-from proton import Connection, Transport, SASL, Endpoint, Delivery, SSL
+import sys, os, subprocess
+from proton import SASL, SSL
 from proton.reactor import Container
 from proton.handlers import CHandshaker, CFlowController
 from string import Template
 
-if sys.version_info[0] == 2 and sys.version_info[1] < 6:
-    # this is for compatibility, apparently the version of jython we
-    # use doesn't have the next() builtin.
-    # we should remove this when we upgrade to a python 2.6+ compatible version
-    # of jython
-    #_DEF = object()  This causes the test loader to fail (why?)
-    class _dummy(): pass
-    _DEF = _dummy
-
-    def next(iter, default=_DEF):
-        try:
-            return iter.next()
-        except StopIteration:
-            if default is _DEF:
-                raise
-            else:
-                return default
-    # I may goto hell for this:
-    import __builtin__
-    __builtin__.__dict__['next'] = next
-
-
 def free_tcp_ports(count=1):
   """ return a list of 'count' TCP ports that are free to used (ie. unbound)
   """


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


Mime
View raw message