diff options
Diffstat (limited to 'recipes-networking/openvswitch/openvswitch-git/0007-Python3-compatibility-unicode-to-str.patch')
-rw-r--r-- | recipes-networking/openvswitch/openvswitch-git/0007-Python3-compatibility-unicode-to-str.patch | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/recipes-networking/openvswitch/openvswitch-git/0007-Python3-compatibility-unicode-to-str.patch b/recipes-networking/openvswitch/openvswitch-git/0007-Python3-compatibility-unicode-to-str.patch new file mode 100644 index 00000000..faa32b73 --- /dev/null +++ b/recipes-networking/openvswitch/openvswitch-git/0007-Python3-compatibility-unicode-to-str.patch | |||
@@ -0,0 +1,51 @@ | |||
1 | From 2fe58f87b00d0ec24d6997930d0bcdb130c84396 Mon Sep 17 00:00:00 2001 | ||
2 | From: Jason Wessel <jason.wessel@windriver.com> | ||
3 | Date: Thu, 29 Jun 2017 20:33:23 -0700 | ||
4 | Subject: [PATCH 7/8] Python3 compatibility: unicode to str | ||
5 | |||
6 | Commit 7430959d4ad17db89b8387c3aef58c8b230cad10 from | ||
7 | https://github.com/openvswitch/ovs.git | ||
8 | |||
9 | When transitioning from python2 to python3 the following type class | ||
10 | changes occured: | ||
11 | |||
12 | python2 -> python3 | ||
13 | unicode -> str | ||
14 | str -> bytes | ||
15 | |||
16 | That means we have to check the python version and do the right type | ||
17 | check python3 will throw an error when it tries to use the unicode | ||
18 | type because it doesn't exist. | ||
19 | |||
20 | Signed-off-by: Jason Wessel <jason.wessel@windriver.com> | ||
21 | Signed-off-by: Ben Pfaff <blp@ovn.org> | ||
22 | --- | ||
23 | ovsdb/ovsdb-doc | 12 +++++++++--- | ||
24 | 1 file changed, 9 insertions(+), 3 deletions(-) | ||
25 | |||
26 | diff --git a/ovsdb/ovsdb-doc b/ovsdb/ovsdb-doc | ||
27 | index 918e88a..406c293 100755 | ||
28 | --- a/ovsdb/ovsdb-doc | ||
29 | +++ b/ovsdb/ovsdb-doc | ||
30 | @@ -65,9 +65,15 @@ def columnGroupToNroff(table, groupXml, documented_columns): | ||
31 | if node.hasAttribute('type'): | ||
32 | type_string = node.attributes['type'].nodeValue | ||
33 | type_json = ovs.json.from_string(str(type_string)) | ||
34 | - if type(type_json) in (str, unicode): | ||
35 | - raise error.Error("%s %s:%s has invalid 'type': %s" | ||
36 | - % (table.name, name, key, type_json)) | ||
37 | + # py2 -> py3 means str -> bytes and unicode -> str | ||
38 | + try: | ||
39 | + if type(type_json) in (str, unicode): | ||
40 | + raise error.Error("%s %s:%s has invalid 'type': %s" | ||
41 | + % (table.name, name, key, type_json)) | ||
42 | + except: | ||
43 | + if type(type_json) in (bytes, str): | ||
44 | + raise error.Error("%s %s:%s has invalid 'type': %s" | ||
45 | + % (table.name, name, key, type_json)) | ||
46 | type_ = ovs.db.types.BaseType.from_json(type_json) | ||
47 | else: | ||
48 | type_ = column.type.value | ||
49 | -- | ||
50 | 2.5.0 | ||
51 | |||