oslo.serialization/oslo_serialization
Victor Stinner 92f2111b26 Add jsonutils.dump_as_bytes() function for py3
The jsonutils.dumps() function returns bytes on Python 2 and Unicode
oon Python 3. In some cases, we always want bytes. For example, a
HTTP body must be bytes. This function avoids an condition call to
.encode() depending on the type or on the Python version.

For example:

    body = jsonutils.dumps(data)
    if isinstance(body, six.text_type):
        body = body.encode('utf-8')

can be replaced with:

    body = jsonutils.dump_as_bytes(data)

Change-Id: Ib9d8f1309982762b54d8a91b1f24f64d0ae6723a
2015-09-23 15:23:43 +02:00
..
tests Add jsonutils.dump_as_bytes() function for py3 2015-09-23 15:23:43 +02:00
__init__.py Move files out of the namespace package 2015-01-05 15:40:06 -05:00
jsonutils.py Add jsonutils.dump_as_bytes() function for py3 2015-09-23 15:23:43 +02:00
msgpackutils.py Merge "More docstring cleanups/tweaks" 2015-04-17 19:10:54 +00:00