Merge pull request #51 from Metallicow/pubsub-branch-master2014

PY3 pubsub Fixs
This commit is contained in:
Robin Dunn
2016-02-29 21:43:02 -08:00
7 changed files with 18 additions and 16 deletions

View File

@@ -57,16 +57,16 @@ def getRawFunction(callable_):
recognized type (function, method or has __call__ method)."""
firstArg = 0
if isfunction(callable_):
#print 'Function', getID(callable_)
#print('Function %s' % getID(callable_))
func = callable_
elif ismethod(callable_):
#print 'Method', getID(callable_)
#print('Method %s' % getID(callable_))
func = callable_
if func.__self__ is not None:
# Method is bound, don't care about the self arg
firstArg = 1
elif hasattr(callable_, '__call__'):
#print 'Functor', getID(callable_)
#print('Functor %s' % getID(callable_))
func = callable_.__call__
firstArg = 1 # don't care about the self arg
else:

View File

@@ -49,7 +49,7 @@ def load_module(moduleName, searchPath):
try:
module = _import_module(moduleName)
except:
except Exception:
import imp
fp, pathname, description = imp.find_module(moduleName, searchPath)
try:

View File

@@ -12,9 +12,9 @@ class Message:
via Message.data, while the topic name is available in Message.topic::
def listener(msg):
print "data is ", msg.data
print "topic name is ", msg.topic
print msg
print("data is %s" % msg.data)
print("topic name is %s" % msg.topic)
print(msg)
The example also shows (last line) how a message is convertible to a string.
"""

View File

@@ -72,6 +72,6 @@ class PublisherArg1Stage2(Publisher):
if policies.msgProtocolTransStage is not None:
Publisher = PublisherArg1Stage2
#print 'Using protocol', Publisher
#print('Using protocol %s' % Publisher)

View File

@@ -409,7 +409,7 @@ class Topic(PublisherMixin):
self.__handlingUncaughtListenerExc = False
except Exception:
exc = py2and3.getexcobj()
#print 'exception raised', exc
#print('Exception raised\n%s' % exc)
self.__handlingUncaughtListenerExc = False
raise ExcHandlerError(listener.name(), topicObj, exc)
@@ -437,13 +437,13 @@ class Topic(PublisherMixin):
"""Unsubscribe all our listeners, remove all subtopics from self,
then detach from parent. Parent is not notified, because method
assumes it has been called by parent"""
#print 'Remove %s listeners (%s)' % (self.getName(), self.getNumListeners())
#print('Remove %s listeners (%s)' % (self.getName(), self.getNumListeners()))
self.unsubscribeAllListeners()
self.__parentTopic = None
for subName, subObj in py2and3.iteritems(self.__subTopics):
assert isinstance(subObj, Topic)
#print 'Unlinking %s from parent' % subObj.getName()
#print('Unlinking %s from parent' % subObj.getName())
subObj.__undefineBranch(topicsMap)
self.__subTopics = {}

View File

@@ -1,5 +1,5 @@
"""
Aggregates policies for pubsub. Mainly, related to messaging protocol.
Aggregates policies for pubsub. Mainly, related to messaging protocol.
:copyright: Copyright since 2006 by Oliver Schoenborn, all rights reserved.
:license: BSD, see LICENSE_BSD_Simple.txt for details.
@@ -19,6 +19,8 @@ def setMsgDataArgName(stage, listenerArgName, senderArgNameAny=False):
senderKwargNameAny = senderArgNameAny
msgDataArgName = listenerArgName
msgProtocolTransStage = stage
#print `policies.msgProtocolTransStage`, `policies.msgDataProtocol`, \
# `policies.senderKwargNameAny`, `policies.msgDataArgName`
#print 'override "arg1" protocol arg name:', argName
#print('%s' % repr(policies.msgProtocolTransStage))
#print('%s' % repr(policies.msgDataProtocol))
#print('%s' % repr(policies.senderKwargNameAny))
#print('%s' % repr(policies.msgDataArgName))
#print('override "arg1" protocol arg name: %s' % argName)

View File

@@ -79,7 +79,7 @@ def _get_elem(elem):
if not ET.iselement(elem):
try:
elem = ET.fromstring(elem)
except:
except Exception:
py2and3.print_("Value Error", elem)
raise ValueError("Cannot convert to element")
return elem