]> git.proxmox.com Git - mirror_ovs.git/commitdiff
Python3 compatibility: unicode to str
authorJason Wessel <jason.wessel@windriver.com>
Fri, 30 Jun 2017 03:33:23 +0000 (20:33 -0700)
committerBen Pfaff <blp@ovn.org>
Thu, 6 Jul 2017 21:06:08 +0000 (14:06 -0700)
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>
ovsdb/ovsdb-doc

index 918e88ab3b924a1a479d4b5535ea763c188dff8a..406c293114657617a47ff10c7d47f7c41b24ad14 100755 (executable)
@@ -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