Fix the issue that the function unpackb has no encoding option
Package msgpack has Removed the encoding option. Please refer to [1]. And the default encoding of python3 is 'utf-8', So there is no need to specify the encoding as 'utf-8'. [1] https://github.com/msgpack/msgpack-python/pull/380/files Change-Id: Ibb92e983a79e5c1608f6a603816e1b88283e34c9 Closes-Bug: #1891008 Signed-off-by: ZijianGuo <guozijn@gmail.com>
This commit is contained in:
parent
e12c65a369
commit
8baa824b85
@ -16,7 +16,7 @@ jsonschema==2.6.0
|
||||
keystoneauth1==3.4.0
|
||||
keystonemiddleware==4.17.0
|
||||
mock==2.0.0
|
||||
msgpack==0.5.1
|
||||
msgpack==1.0.0
|
||||
os-api-ref==1.4.0
|
||||
os-client-config==1.28.0
|
||||
os-testr==1.0.0
|
||||
|
@ -10,7 +10,7 @@ falcon>=1.1.0 # Apache-2.0
|
||||
jsonschema>=2.6.0 # MIT
|
||||
iso8601>=0.1.11 # MIT
|
||||
keystonemiddleware>=4.17.0 # Apache-2.0
|
||||
msgpack>=0.5.1 # Apache-2.0
|
||||
msgpack>=1.0.0 # Apache-2.0
|
||||
python-memcached>=1.56 # PSF
|
||||
python-swiftclient>=3.2.0 # Apache-2.0
|
||||
WebOb>=1.7.1 # MIT
|
||||
|
@ -148,7 +148,7 @@ def caches(keygen, ttl, cond=None):
|
||||
else:
|
||||
# NOTE(kgriffs): unpackb does not default to UTF-8,
|
||||
# so we have to explicitly ask for it.
|
||||
value = msgpack.unpackb(packed_value, encoding='utf-8')
|
||||
value = msgpack.unpackb(packed_value)
|
||||
|
||||
return value
|
||||
|
||||
|
@ -85,9 +85,8 @@ class ClaimController(storage.Claim, scripting.Mixin):
|
||||
super(ClaimController, self).__init__(*args, **kwargs)
|
||||
self._client = self.driver.connection
|
||||
|
||||
self._packer = msgpack.Packer(encoding='utf-8',
|
||||
use_bin_type=True).pack
|
||||
self._unpacker = functools.partial(msgpack.unpackb, encoding='utf-8')
|
||||
self._packer = msgpack.Packer(use_bin_type=True).pack
|
||||
self._unpacker = functools.partial(msgpack.unpackb)
|
||||
|
||||
@decorators.lazy_property(write=False)
|
||||
def _queue_ctrl(self):
|
||||
|
@ -69,9 +69,8 @@ class FlavorsController(base.FlavorsBase):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(FlavorsController, self).__init__(*args, **kwargs)
|
||||
self._client = self.driver.connection
|
||||
self._packer = msgpack.Packer(encoding='utf-8',
|
||||
use_bin_type=True).pack
|
||||
self._unpacker = functools.partial(msgpack.unpackb, encoding='utf-8')
|
||||
self._packer = msgpack.Packer(use_bin_type=True).pack
|
||||
self._unpacker = functools.partial(msgpack.unpackb)
|
||||
|
||||
@utils.raises_conn_error
|
||||
def list(self, project=None, marker=None, limit=10, detailed=False):
|
||||
|
@ -250,8 +250,8 @@ class Message(MessageEnvelope):
|
||||
# ==========================================================================
|
||||
|
||||
|
||||
_pack = msgpack.Packer(encoding='utf-8', use_bin_type=True).pack
|
||||
_unpack = functools.partial(msgpack.unpackb, encoding='utf-8')
|
||||
_pack = msgpack.Packer(use_bin_type=True).pack
|
||||
_unpack = functools.partial(msgpack.unpackb)
|
||||
|
||||
|
||||
def _hmap_kv_to_msgenv(keys, values):
|
||||
|
@ -87,9 +87,8 @@ class PoolsController(base.PoolsBase):
|
||||
super(PoolsController, self).__init__(*args, **kwargs)
|
||||
self._client = self.driver.connection
|
||||
self.flavor_ctl = self.driver.flavors_controller
|
||||
self._packer = msgpack.Packer(encoding='utf-8',
|
||||
use_bin_type=True).pack
|
||||
self._unpacker = functools.partial(msgpack.unpackb, encoding='utf-8')
|
||||
self._packer = msgpack.Packer(use_bin_type=True).pack
|
||||
self._unpacker = functools.partial(msgpack.unpackb)
|
||||
|
||||
@utils.raises_conn_error
|
||||
@utils.retries_on_connection_error
|
||||
|
@ -63,9 +63,8 @@ class QueueController(storage.Queue):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(QueueController, self).__init__(*args, **kwargs)
|
||||
self._client = self.driver.connection
|
||||
self._packer = msgpack.Packer(encoding='utf-8',
|
||||
use_bin_type=True).pack
|
||||
self._unpacker = functools.partial(msgpack.unpackb, encoding='utf-8')
|
||||
self._packer = msgpack.Packer(use_bin_type=True).pack
|
||||
self._unpacker = functools.partial(msgpack.unpackb)
|
||||
|
||||
@decorators.lazy_property(write=False)
|
||||
def _claim_ctrl(self):
|
||||
|
@ -48,9 +48,8 @@ class SubscriptionController(base.Subscription):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SubscriptionController, self).__init__(*args, **kwargs)
|
||||
self._client = self.driver.connection
|
||||
self._packer = msgpack.Packer(encoding='utf-8',
|
||||
use_bin_type=True).pack
|
||||
self._unpacker = functools.partial(msgpack.unpackb, encoding='utf-8')
|
||||
self._packer = msgpack.Packer(use_bin_type=True).pack
|
||||
self._unpacker = functools.partial(msgpack.unpackb)
|
||||
|
||||
@utils.raises_conn_error
|
||||
@utils.retries_on_connection_error
|
||||
|
@ -83,8 +83,7 @@ class TestDecorators(base.TestBase):
|
||||
self.assertEqual(1, instance.project_gets)
|
||||
|
||||
# Should be in the cache now.
|
||||
project = msgpack.unpackb(cache.get(create_key(*args)),
|
||||
encoding='utf-8')
|
||||
project = msgpack.unpackb(cache.get(create_key(*args)))
|
||||
self.assertEqual(sample_project, project)
|
||||
|
||||
# Should read from the cache this time (counter will not
|
||||
@ -128,7 +127,7 @@ class TestDecorators(base.TestBase):
|
||||
self.assertEqual(1, instance.user_gets)
|
||||
|
||||
# Should be in the cache now.
|
||||
user = msgpack.unpackb(cache.get(name), encoding='utf-8')
|
||||
user = msgpack.unpackb(cache.get(name))
|
||||
self.assertEqual(name, user)
|
||||
|
||||
# Should read from the cache this time (counter will not
|
||||
|
@ -38,8 +38,8 @@ def get_pack_tools(binary=None):
|
||||
if binary is None:
|
||||
raise Exception("binary param is unspecified")
|
||||
if binary:
|
||||
dumps = msgpack.Packer(encoding='utf-8', use_bin_type=False).pack
|
||||
loads = functools.partial(msgpack.unpackb, encoding='utf-8')
|
||||
dumps = msgpack.Packer(use_bin_type=False).pack
|
||||
loads = functools.partial(msgpack.unpackb)
|
||||
create_request_function = create_binary_request
|
||||
else:
|
||||
dumps = json.dumps
|
||||
|
@ -347,8 +347,7 @@ class SubscriptionTest(base.V1_1Base):
|
||||
# Check that the server sent the websocket notification in binary
|
||||
# format
|
||||
self.assertEqual(3, sender.call_count)
|
||||
ws_notification = msgpack.unpackb(sender.call_args_list[2][0][0],
|
||||
encoding='utf-8')
|
||||
ws_notification = msgpack.unpackb(sender.call_args_list[2][0][0])
|
||||
self.assertEqual({'body': {'status': 'disco queen'}, 'ttl': 60,
|
||||
'queue_name': 'kitkat',
|
||||
'Message_Type': u'Notification'}, ws_notification)
|
||||
|
@ -80,7 +80,7 @@ class MessagingProtocol(websocket.WebSocketServerProtocol):
|
||||
# Deserialize the request
|
||||
try:
|
||||
if isBinary:
|
||||
payload = msgpack.unpackb(payload, encoding='utf-8')
|
||||
payload = msgpack.unpackb(payload)
|
||||
else:
|
||||
if isinstance(payload, bytes):
|
||||
payload = payload.decode()
|
||||
|
Loading…
Reference in New Issue
Block a user