diff options
author | Jason Wessel <jason.wessel@windriver.com> | 2017-06-29 20:33:23 -0700 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2017-07-06 14:06:08 -0700 |
commit | 7430959d4ad17db89b8387c3aef58c8b230cad10 (patch) | |
tree | 80d887bf529e5ce2e58f3a9257e6c9358dab9597 /ovsdb | |
parent | 3fa5aa4294377e0f35267936d0c5caea3e61db48 (diff) | |
download | openvswitch-7430959d4ad17db89b8387c3aef58c8b230cad10.tar.gz |
Python3 compatibility: unicode to str
When transitioning from python2 to python3 the following type class
changes occured:
python2 -> python3
unicode -> str
str -> bytes
That means we have to check the python version and do the right type
check python3 will throw an error when it tries to use the unicode
type because it doesn't exist.
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'ovsdb')
-rwxr-xr-x | ovsdb/ovsdb-doc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/ovsdb/ovsdb-doc b/ovsdb/ovsdb-doc index 918e88ab3..406c29311 100755 --- a/ovsdb/ovsdb-doc +++ b/ovsdb/ovsdb-doc @@ -65,9 +65,15 @@ def columnGroupToNroff(table, groupXml, documented_columns): if node.hasAttribute('type'): type_string = node.attributes['type'].nodeValue type_json = ovs.json.from_string(str(type_string)) - if type(type_json) in (str, unicode): - raise error.Error("%s %s:%s has invalid 'type': %s" - % (table.name, name, key, type_json)) + # py2 -> py3 means str -> bytes and unicode -> str + try: + if type(type_json) in (str, unicode): + raise error.Error("%s %s:%s has invalid 'type': %s" + % (table.name, name, key, type_json)) + except: + if type(type_json) in (bytes, str): + raise error.Error("%s %s:%s has invalid 'type': %s" + % (table.name, name, key, type_json)) type_ = ovs.db.types.BaseType.from_json(type_json) else: type_ = column.type.value |