summaryrefslogtreecommitdiff
path: root/python/ovs/json.py
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-05-13 14:20:10 -0700
committerBen Pfaff <blp@nicira.com>2011-05-24 11:32:22 -0700
commitbe44585c21cc8dbe097a460a930696f0350dc12d (patch)
tree764ac76d7386879748e3b4fd0e43fc797923bd70 /python/ovs/json.py
parent19997ceee06cec2ce1f36ebfc225fa379b6b1ed0 (diff)
downloadopenvswitch-be44585c21cc8dbe097a460a930696f0350dc12d.tar.gz
tests: Fix the two Python XFAIL tests.
OVS has two Python tests that have always failed, for reasons not understood, since they were added to the tree. This commit fixes them. One problem was that Python was assuming that stdout was encoded in ASCII. Apparently the only way to "fix" this at runtime is to set PYTHONIOENCODING to utf_8 in the environment, so this change does that. Second, it appears that Python really doesn't like to print invalid UTF-8, so this avoids doing that in python/ovs/json.py, instead just printing the hexadecimal values of the invalid bytes. For consistency, it makes the same change to the C version. Third, the C version of test-ovsdb doesn't check UTF-8 for consistency, it just sends it blindly to the OVSDB server, but Python does check it and so it bails out earlier. This commit changes the Python version of the "no invalid UTF-8 sequences in strings" to allow for the slight difference in output that occurs for that reason. Finally, test-ovsdb.py needs to convert error messages to Unicode explicitly before printing them in the "parse-atoms" function. I don't really understand why, but now it works.
Diffstat (limited to 'python/ovs/json.py')
-rw-r--r--python/ovs/json.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/python/ovs/json.py b/python/ovs/json.py
index 1e26a6290..f8b02d180 100644
--- a/python/ovs/json.py
+++ b/python/ovs/json.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2010 Nicira Networks
+# Copyright (c) 2010, 2011 Nicira Networks
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -114,9 +114,7 @@ def from_string(s):
s = unicode(s, 'utf-8')
except UnicodeDecodeError, e:
seq = ' '.join(["0x%2x" % ord(c) for c in e.object[e.start:e.end]])
- raise Error("\"%s\" is not a valid UTF-8 string: "
- "invalid UTF-8 sequence %s" % (s, seq),
- tag="constraint violation")
+ return ("not a valid UTF-8 string: invalid UTF-8 sequence %s" % seq)
p = Parser(check_trailer=True)
p.feed(s)
return p.finish()