All of the negative Python OVSDB tests were failing on Python 2.6 because
"%s\n" % e yielded the empty string on that version of Python. In turn,
that was because ovs.db.error.Error.__unicode__ was being called instead of
ovs.db.error.Error.__str__. I'm puzzled why that was happening, but this
commit fixes it and also seems like a small code cleanup.
Peter Balland helped me gain some insight on this problem.
CC: Peter Balland <peter@nicira.com>
CC: Reid Price <reid@nicira.com>
class Error(Exception):
def __init__(self, msg, json=None, tag=None):
- Exception.__init__(self)
self.msg = msg
self.json = json
if tag is None:
else:
self.tag = tag
- def __str__(self):
+ # Compose message.
syntax = ""
if self.json is not None:
syntax = "syntax \"%s\": " % ovs.json.to_string(self.json)
- return "%s%s: %s" % (syntax, self.tag, self.msg)
+ Exception.__init__(self, "%s%s: %s" % (syntax, self.tag, self.msg))