From: Ben Pfaff Date: Tue, 2 Nov 2010 20:13:12 +0000 (-0700) Subject: ovsdb: Fix formatting of ovs.db.Error on Python 2.6. X-Git-Tag: v1.1.0~944 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=0f9fc40325e390f23ef46cb2b3588da6b97ad5b1;p=sliver-openvswitch.git ovsdb: Fix formatting of ovs.db.Error on Python 2.6. 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 CC: Reid Price --- diff --git a/python/ovs/db/error.py b/python/ovs/db/error.py index 084db6e2e..882518cb1 100644 --- a/python/ovs/db/error.py +++ b/python/ovs/db/error.py @@ -16,7 +16,6 @@ import ovs.json class Error(Exception): def __init__(self, msg, json=None, tag=None): - Exception.__init__(self) self.msg = msg self.json = json if tag is None: @@ -27,8 +26,8 @@ class Error(Exception): 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))