Browse Source

Make compatible with msgpack 1.0.0

There are a couple of things that changed in msgpack 1.0.0 that were
breaking oslo.privsep:

1) The encoding parameter to Unpacker was removed. This has been
   deprecated for a while in favor of the `raw` parameter[0], so this
   change switches to using raw.

2) The strict_map_key parameter default was changed from False to
   True.[1] I haven't found an explanation of why this was done, but
   we can explicitly set it False to maintain the previous behavior.

Closes-Bug: 1855914
Closes-Bug: 1864811
0: https://msgpack-python.readthedocs.io/en/latest/api.html#msgpack.Unpacker
1: 6e1d12c0a2

Change-Id: Ia97ecf965d807f12524d5b6602446934b5813ce6
Closes-Bug: 1899140
(cherry picked from commit f19765c683ce847f8d0ae0499d9e67c41114c0b7)
changes/33/757033/3 1.33.5
Ben Nemec 10 months ago
committed by Hervé Beraud
parent
commit
ced0e7b33b
1 changed files with 16 additions and 2 deletions
  1. +16
    -2
      oslo_privsep/comm.py

+ 16
- 2
oslo_privsep/comm.py View File

@ -65,8 +65,22 @@ class Serializer(object):
class Deserializer(six.Iterator):
def __init__(self, readsock):
self.readsock = readsock
self.unpacker = msgpack.Unpacker(use_list=False, encoding='utf-8',
unicode_errors='surrogateescape')
# (hberaud): Sometime msgpack's versions are not properly aligned with
# constraints and we need to stay compat with the available version.
# By example 1.0.0 dropped the encoding param but previous
# version doesn't define the raw params too.
# So here we use the right signature which fit our needs.
try:
self.unpacker = msgpack.Unpacker(
use_list=False,
encoding='utf-8',
unicode_errors='surrogateescape')
except TypeError:
self.unpacker = msgpack.Unpacker(
use_list=False,
raw=False,
strict_map_key=False,
unicode_errors='surrogateescape')
def __iter__(self):
return self


Loading…
Cancel
Save