19 Commits

Author SHA1 Message Date
Stephen Finucane
ad356ea9c2 Drop use of six
Another one bites the dust.

Change-Id: I1fadcad8219322b569eeecd81e454a44641e8b1e
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2020-03-02 10:10:22 +00:00
Morgan
d5855294a8 Stop using encoding='utf-8' with msgpack
msgpack is throwing a warning that the unpacker has deprecated the use
of encoding argument. Instead the unpacker uses `raw=False`, which
does an unpack with similar behavior to the old encoding='utf-8'
mechanism.

This will reduce a lot of warning spam for projects using msgpack
such as Keystone. The change to the kwarg "raw" from "bytes_as_raw"
happned between 0.5.1 and 0.5.2. Changing the lower constraint is
required to ensure the new arguments are matching the method
signature.

Change-Id: Iadbee3ec8def9512369a415fb4603dc05d0cbc56
2018-06-03 00:25:50 -07:00
gecong1973
1df76ee42d Replace six.iteritems() with .items()
1.As mentioned in [1], we should avoid using
six.iteritems to achieve iterators. We can use
dict.items instead, as it will return iterators
in PY3 as well. And dict.items/keys will more readable.
2.In py2, the performance about list should be negligible,
see the link [2].
[1] https://wiki.openstack.org/wiki/Python3
[2] http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html

Change-Id: Ifbe7929580ec61a2cd50232794c0cbd0cbf37edc
2016-12-12 11:11:28 +08:00
Gevorg Davoian
4fdaeff758 Replace TypeError by ValueError in msgpackutils
There are some differences in the behaviour of json and msgpack
serializers. Msgpack throws TypeError when it doesn't know
how to handle an object. Json throws ValueError instead. Regarding
the fact that serialization should be configurable (in particular,
serializers should have similar behaviour; right now transition from
json to msgpack leads to errors and fails) this patch proposes to
raise ValueError instead of TypeError on failures so that libraries
already using jsonutils would be able to also work with msgpackutils.

Change-Id: I3d21b7d136e5a426a3c4a70a953c82ddcd6ef5af
2016-06-08 08:41:36 +00:00
Jenkins
8cb124e149 Merge "Make msgpack registries copyable (and add __contains__)" 2016-03-24 02:51:19 +00:00
Joshua Harlow
056d701620 Make msgpack registries copyable (and add __contains__)
In order to make it easy to extend the default msgpack extension
registry add a copy method to registries and select type handlers
so that a registry with additional values can be easily provided
to the various msgpack utils loads/dumps code.

This also re-adds the msgpackutils tests which appear to have
not shifted over (or otherwise disappeared somehow?) from when the
tests used to live in the root directory.

Closes-Bug: #1537716

Change-Id: I9785a9071044d0e8c044a36ae9af9912fd06c49d
2016-03-14 22:16:51 -07:00
Mehdi Abaakouk
da1475a28f msgpack: fix datetime serialization
If the datetime is serialized with python2 and deserializer
with python3 we got KeyError, because python3 will read
the data written with python2 as bytes and doesn't convert it in unicode.

So ensure we use always unicode everywhere.

Change-Id: I4bee7369a278fa7705cde860c68e133cee2fa79e
Closes-bug: #1556081
2016-03-14 16:56:18 +01:00
ChangBo Guo(gcb)
550afa9c0e msgpackutils: drop Python 2.6 support
We doesn't support python 2.6 now, this commit
removes Python 2.6 related code in module msgpackutls.

Change-Id: Id148239ee6c1ad461188fa38b06ca0d7913d7454
2015-11-21 12:18:30 +08:00
Victor Stinner
2d085d2c17 Use versionadded and versionchanged in doc
Document in which version new types and functions were added using
".. versionadded:: x.y". Document changes using
".. versionchanged:: x.y."

For base64 module, add the versionadded tag in the module top
docstring, not on each type/function.

I used "git blame" + "git tag --contains=SHA1" to find these version,
and then I checked manually each version.

Change-Id: I4a891b18064fe7b857a79c57030ff31f7a0370b4
2015-10-15 14:38:50 +02:00
Jenkins
e52fdfaf18 Merge "More docstring cleanups/tweaks" 2015-04-17 19:10:54 +00:00
Jenkins
2df5edaa9b Merge "Add docstring(s) to handler registry(s)" 2015-04-17 19:10:47 +00:00
Joshua Harlow
6665672e3f Expose base msgpack exceptions so users don't need to import
Change-Id: Ibcea72f8b67d08231e755b684056aa3ab1b03442
2015-04-16 11:27:46 -07:00
Joshua Harlow
4ada51b09d More docstring cleanups/tweaks
Ensure jsonutils and msgpackutils headers are linkable and
connect into there associated functions and classes so that
clicking on links works (instead of not working).

Change-Id: Ifa28421e7d21a85290ee13d04918325c3f991b92
2015-04-14 21:09:14 +00:00
Joshua Harlow
58c1f29080 Add docstring(s) to handler registry(s)
Ensure that the handler registry (and the default
registry) appears in the generated docs and make sure that a
note is added that we can not currently serialize and restore
tuples correctly (at least until the mentioned pull request is
merged and a release is made avaiable with it).

Change-Id: Ic5b9c41b401c6983bd416fd6726319cc674c1759
2015-04-14 14:08:23 -07:00
Joshua Harlow
c7898c2c9d Make the msgpackutils handlers more extendable
This change revamps the current serialization and
deserialization functions to be tiny objects that
have the ability to serialize there expected types.

It also adds a registry of these handlers objects
and allows for passing a registry into the dumps
and loads methods for people that want to add there
own handlers on.

Change-Id: Ib1a8a507c6c3d4f0372114d67163d3f2ab495c9f
2015-03-31 17:29:41 -07:00
Joshua Harlow
2857ee3b68 Correctly load and dump items with datetime.date(s)
Change-Id: I3fbe21df4b5ac12d13dd8633b7c362aeabbfc94f
2015-02-12 04:55:56 +00:00
Joshua Harlow
9f2a2edb56 Avoid using strtime for serializing datetimes
The timeutils module already provides a better
marshall/unmarshall routine that doesn't use strtime
but uses dictionary conversion instead so we should
just use that (to avoid the weirdness with strtime).

Change-Id: Ia7c88ec4266f914d0c89b67a3fb2b936cc1a1c93
2015-02-11 20:55:51 -08:00
Doug Hellmann
402abdbcd0 Update Oslo imports to remove namespace package
Change-Id: I4ec9b2a310471e4e07867073e9577731ac34027d
Blueprint: drop-namespace-packages
2015-01-21 19:54:33 -05:00
Joshua Harlow
2a30128b72 Add a messagepack utils helper module
Messagepack is used by some projects, so providing a more
featureful encoding/decoding functionality that works better
with specialized types such as datetime, uuids and so-on in
a customized manner would be quite useful for those projects
that use it so they don't blow up when encoding and don't need
to resort to lossy serialization (by using jsonutils).

Change-Id: I295bfca0737301d15414410822bfbb28f66370dd
2015-01-15 10:53:36 -08:00