Run the following command on Xenserver:
PYTHONPATH=`pwd`/python/compat::`pwd`/python python ./tests/test-ovsdb.py \
parse-atoms '{"type": "string", "minLength": 2}'    \
 '[""]'     '["a"]'     '["ab"]'     '["abc"]'     '["\ud834\udd1e"]'

And we get the following error:
UnicodeEncodeError: 'ascii' codec can't encode character u'\U0001d11e'
in position 23: ordinal not in range(128).

It looks like we are hitting the following bug:
http://bugs.python.org/issue2517

Signed-off-by: Gurucharan Shetty <gshe...@nicira.com>
---
In addition to the above bug, I see some other wierdness while dealing with
unicode on Xenserver and Python 2.4.3 . As an example, the following diff
would work fine if python is run from command line but not from inside
testsuite. When run from inside the testsuite we get the same unicode error.
I am not sure why.

diff --git a/python/ovs/db/data.py b/python/ovs/db/data.py
index 6baff38..532ecdd 100644
--- a/python/ovs/db/data.py
+++ b/python/ovs/db/data.py
@@ -164,6 +164,9 @@ class Atom(object):
             s = self.value
             length = len(s)
             if length < base.min_length:
+                a = 'constraint violation: "%s" length %d is less than'\
+                    ' minimum allowed length %d' % (s, length, base.min_length)
+               print unicode(a)
                 raise ConstraintViolation(
                     '"%s" length %d is less than minimum allowed length %d'
                     % (s, length, base.min_length))
---
 tests/test-ovsdb.py |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/test-ovsdb.py b/tests/test-ovsdb.py
index 392ed4b..cec46bd 100644
--- a/tests/test-ovsdb.py
+++ b/tests/test-ovsdb.py
@@ -105,7 +105,7 @@ def do_parse_atoms(type_string, *atom_strings):
             atom = data.Atom.from_json(base, atom_json)
             print ovs.json.to_string(atom.to_json())
         except error.Error, e:
-            print unicode(e)
+            print e.args[0].encode("utf8")
 
 
 def do_parse_data(type_string, *data_strings):
-- 
1.7.9.5

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to