Commit Graph

22 Commits

Author SHA1 Message Date
Hervé Beraud 61c460f3f2 Fix compatibility with Python 3.8
We removed compatibility with Python 3.8 once but it was added back to
tested runtimes for 2023.2. Thus we have to make sure the code works
with Python 3.8, which was broken by [1].

Note that pytz is added back to requirmenets.txt and is now required
regardless of the python version. This is a short term solution until
we figure out the way to fix the requirement-check job (or we again
remove python 3.8 support).

[1] a326ec5eea

Change-Id: I3b222bb59260dff7a06a5ed48720df3dc8c74ea7
2023-05-16 10:24:51 +02:00
Hervé Beraud a326ec5eea Implement zoneinfo support to drop dependency to pytz
Zoneinfo was introduced within python 3.9.

The support of pytz will be removed within RHEL 10 [1].

2023.2 (bobcat) will move our testing runtime to py3.9 and py3.10
so we want to see pytz removed within this series.

tzdata is required at runtime in our gates, because, by default,
zoneinfo uses the system’s time zone data if available; if no system
time zone data is available, the library will fall back to using the
first-party tzdata package available on PyPI. Apparently our gates have no
time zone data available nor tzdata installed by default because we get the
following error without tzdata installed [3]:
`ModuleNotFoundError: No module named 'tzdata'

So I prefer to add tzdata in our requirements to avoid runtime failure
related to time zone and ensure that time zone are always available.

[1] https://issues.redhat.com/browse/RHEL-219
[2] https://review.opendev.org/c/openstack/governance/+/872232
[3]
https://zuul.opendev.org/t/openstack/build/0a1576775e894b09bc31269fea00ba03/log/job-output.txt#1445`

Depends-on: https://review.opendev.org/c/openstack/requirements/+/875854
Change-Id: I8d87d54f6f5ded8caee6cb780bacb39afea0fea1
2023-03-23 17:17:59 +01:00
songwenping 0f5451555b Remove unnecessary unicode prefixes
Change-Id: I0910f62e7feaf928fe0afe4721c5b271d4748449
2022-04-19 19:48:16 +08:00
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