Browse Source

Merge "Set unicode_errors handler to 'surrogateescape' in msgpack"

Zuul 3 months ago
parent
commit
6b5bbbb148
2 changed files with 5 additions and 3 deletions
  1. 4
    2
      oslo_privsep/comm.py
  2. 1
    1
      oslo_privsep/tests/test_comm.py

+ 4
- 2
oslo_privsep/comm.py View File

@@ -51,7 +51,8 @@ class Serializer(object):
51 51
         self.writesock = writesock
52 52
 
53 53
     def send(self, msg):
54
-        buf = msgpack.packb(msg, use_bin_type=True)
54
+        buf = msgpack.packb(msg, use_bin_type=True,
55
+                            unicode_errors='surrogateescape')
55 56
         self.writesock.sendall(buf)
56 57
 
57 58
     def close(self):
@@ -64,7 +65,8 @@ class Serializer(object):
64 65
 class Deserializer(six.Iterator):
65 66
     def __init__(self, readsock):
66 67
         self.readsock = readsock
67
-        self.unpacker = msgpack.Unpacker(use_list=False, encoding='utf-8')
68
+        self.unpacker = msgpack.Unpacker(use_list=False, encoding='utf-8',
69
+                                         unicode_errors='surrogateescape')
68 70
 
69 71
     def __iter__(self):
70 72
         return self

+ 1
- 1
oslo_privsep/tests/test_comm.py View File

@@ -72,7 +72,7 @@ class TestSerialization(base.BaseTestCase):
72 72
         self.assertSendable(data)
73 73
 
74 74
     def test_unicode(self):
75
-        data = u'\u4e09\u9df9'
75
+        data = u'\u4e09\u9df9\udc82'
76 76
         self.assertSendable(data)
77 77
 
78 78
     def test_tuple(self):

Loading…
Cancel
Save