Commit Graph

192 Commits

Author SHA1 Message Date
Andreas Jaeger ab82bf23bf Retire repo
This repo was created by accident, use deb-python-oslo.serialization
instead.

Needed-By: I1ac1a06931c8b6dd7c2e73620a0302c29e605f03
Change-Id: I81894aea69b9d09b0977039623c26781093a397a
2017-04-17 19:39:43 +02:00
Jenkins 1f86a66a36 Merge "Fix serialization of binary strings in Python3" 2016-08-04 13:31:57 +00:00
xianming.mao d8e6057b31 Drop H803 in flake8 ignore list
In hacking >=0.10.0,there is not H803.We should remove it.

Change-Id: I4738aba1d02ad1404944a326f1ce5538dd1edc7a
2016-08-03 14:08:31 +08:00
Gevorg Davoian a73120aad6 Fix serialization of binary strings in Python3
Change-Id: I30e7c7b7cb2356a39bc51eb8c93f14c8881a38c2
Closes-Bug: #1599387
2016-08-01 16:58:08 +03:00
OpenStack Proposal Bot afb53323a1 Updated from global requirements
Change-Id: Ib76f363aba1eaf059799c4b954ddf296269ff390
2016-07-29 02:34:03 +00:00
yanheven 5ae04325e6 Fix parameters of assertEqual are misplaced
Many assertEqual sentences don't follow assertEqual(expected, actual),
These misplaces have 2 impacts:
1, giving confusing messages when some tests failed.
2, mislead other developers, new test modules may follow these wrong pattern.

This patch fix all of them.

Change-Id: Ice3148685b81bf906672b91159fbb29bd618abb0
Closes-Bug: #1604213
2016-07-23 19:38:43 +08:00
ChangBo Guo(gcb) aa0e48021a Add Python 3.5 classifier and venv
Now that there is a passing gate job, we can claim support for
Python 3.5 in the classifier. This patch also adds the convenience
py35 venv.

Change-Id: I6f67834cc0f6f204aba2457f71e788d1fafd2640
2016-07-12 16:53:18 +08:00
OpenStack Proposal Bot 7ad9a95800 Updated from global requirements
Change-Id: I4e8b08864afacea4261d48e403ce159faae36da8
2016-07-09 19:26:04 +00:00
OpenStack Proposal Bot 5ee90fcb0e Updated from global requirements
Change-Id: I6ffc7b5b8ba947ce08c5e2484a4536b7719d9581
2016-06-30 18:48:37 +00:00
Edan David 1ec85e90cd Use {} instead of dict()
There is a performance impact when using dict() instead of {}
in CPython (up to 6 times longer).
Considering the to_primitive function is recursive this can
have quite an effect.

Measuring:
$ python2.7 -m timeit -n 1000000 -r 5 -v 'dict()'
raw times: 0.24 0.24 0.24 0.239 0.24
1000000 loops, best of 5: 0.239 usec per loop

$ python2.7 -m timeit -n 1000000 -r 5 -v '{}'
raw times: 0.0417 0.0413 0.0407 0.0411 0.042
1000000 loops, best of 5: 0.0407 usec per loop

For more information:
https://doughellmann.com/blog/2012/11/12/
the-performance-impact-of-using-dict-instead-of-in-cpython-2-7-2/

Change-Id: Ia0b5892773a19cbabe40313a3bc788580a943f53
2016-06-21 10:58:06 -04:00
OpenStack Proposal Bot 23866b6d6c Updated from global requirements
Change-Id: I177163b1f2739abb83b88c561da8c92701c860cc
2016-06-09 16:13:02 +00:00
Jenkins 0aa1638408 Merge "Support serializing ipaddress objs with jsonutils" 2016-06-09 08:18:25 +00: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
Jim Baker 8943c73662 Support serializing ipaddress objs with jsonutils
Fixes jsonutils.to_primitive so that it can serialize ipaddress
objects, as used by Python 3 or through the backport in
global-requirements.txt. Current support for netaddr is maintained.

Change-Id: I6aa1ecd5be754f61cdda4e47bc0e0180e232b366
Closes-bug: 1590076
2016-06-07 14:05:50 -06:00
OpenStack Proposal Bot 8a4cac92bc Updated from global requirements
Change-Id: Iecdb59fdb7059e74c59e9414b4516cccbb96b828
2016-06-01 13:53:25 +00:00
OpenStack Proposal Bot 9bb6d42532 Updated from global requirements
Change-Id: Idfafa1e4760f2b2e3bd2c6f9c6d5f36278e07e06
2016-05-31 03:05:31 +00:00
OpenStack Proposal Bot bfb15368d1 Updated from global requirements
Change-Id: I6ed13473585c1968f491fc113866d193676a2aef
2016-05-26 17:04:07 +00:00
ChangBo Guo(gcb) 0dcd927163 Trivial: ignore openstack/common in flake8 exclude list
The directory openstack/common doesn't exist any more.
So remove it from flake8 exclude list.

Change-Id: Id3c23fb9f05c50943e1c83be0f0ae577cf762e18
2016-05-11 20:43:42 +08:00
ZhiQiang Fan 8a71061625 [Trivial] Remove executable privilege of doc/source/conf.py
It is a configuration file, rather than a script.

Change-Id: I930d84c9d3f774bfaf98b11e8ef6189f722fe98c
2016-04-29 20:14:26 +08:00
Joshua Harlow 8985675d98 Drop babel as requirement since its not used
See the following thread for more details.

http://lists.openstack.org/pipermail/openstack-dev/2016-April/thread.html#92510

Change-Id: I9858ca0961da0df82f4313b7fd91bb80a2b8935c
2016-04-20 18:44:56 -07:00
OpenStack Proposal Bot 82758dacc0 Updated from global requirements
Change-Id: I9f2ffebde681dae012801cdb54600002bdb44570
2016-04-13 12:47:41 +00:00
Jenkins 4217a25d40 Merge "Unified and simplified API for all serializers" 2016-04-08 01:55:32 +00:00
Gevorg Davoian 7ac405ce65 Unified and simplified API for all serializers
This patch is a proposition to the oslo.serialization for making a
more convenient API. Let me explain briefly why the current library
isn't very convenient for its users. Imagine that a library user
want to implement a function having some (de-)serialization inside.
The user also wants to make serialization configurable through
an additional argument to the function (e.g. some id like "json",
"msgpack" etc.). One can achieve this behaviour by importing all
necessary serializers (an import per a serializer) and adding
some logic for selecting an appropriate serialization mechanism
depending on id. But what if some new serializer is added to the
oslo.serialization? Then all users of the library will have to make
changes in their code. It's not good, and I think it would be better
if all changes concerning serializers were in the oslo.serialization
library. Therefore I think it is a good idea to have a module which
will bring together all implemented serializers under a unified and
somewhat simplified (because in most cases default values for some
parameters are fine) object oriented API, so that future users of the
library will be able to get any available serializer by its id
(importing only one module). Also it is worth saying that the patch
doesn't affect already written code, so there won't be any problems
with the backward compatibility.

May be this implementation isn't the best one, but I hope
the community will appreciate the idea and propose possible
improvements.

Change-Id: Idb12666255a990dfc8f8ff6b43e941b3481b9c1c
2016-04-04 15:27:16 +03: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
OpenStack Proposal Bot 6b5116b6ff Updated from global requirements
Change-Id: Iced8bfd6e53943cb8b47177646a68523e07fa5b0
2016-02-20 21:59:44 +00:00
OpenStack Proposal Bot abaf968af8 Updated from global requirements
Change-Id: I5941bb05b84fb8d1a6e60eaf3be9c3bb257389dd
2016-01-23 10:35:00 +00:00
OpenStack Proposal Bot b8f2ac8c14 Updated from global requirements
Change-Id: I14a93976fa8b25690d6042e721b365aa20fb6e2d
2016-01-18 22:45:10 +00:00
OpenStack Proposal Bot ef8da69263 Updated from global requirements
Change-Id: Idea92d3bfab4192bf3080cd6c32e392a91bc79ee
2016-01-16 03:31:27 +00:00
Ian Cordasco 29a7702a99 Remove fallback to simplejson in jsonutils
OpenStack has ended support for Python 2.6 in all services and
libraries. We no longer need to support a fallback to simplejson on
Python 2.6 so we can remove this fallback logic.

Closes-bug: 1533337
Change-Id: I613541a37229ff2f3ce269cfa7496223d1ff37d0
2016-01-12 13:53:47 -06:00
ChangBo Guo(gcb) 972d3fd8ae Remove iso8601 dependency
oslo.serialization doesn't use iso8601 in anywhere,
so need remove the dependency.
Change-Id: I5bfcb024d7f831365af93fdfd6122d6d71faf87a
2015-12-16 14:55:29 +08:00
OpenStack Proposal Bot 32b9629573 Updated from global requirements
Change-Id: I9187c178b1f6b13dfe744718de8b865168ac6bac
2015-12-15 18:59:20 +00:00
Jenkins e0ac324934 Merge "Trival: Remove 'MANIFEST.in'" 2015-12-14 05:54:48 +00:00
OpenStack Proposal Bot f4a136ecac Updated from global requirements
Change-Id: I8b116b194760bfe6ef6fdb10b099d51bbda35c8d
2015-12-11 15:24:36 +00:00
ChangBo Guo(gcb) db46cb74c4 Trival: Remove 'MANIFEST.in'
Everything in this file is automatically generated by pbr. There
appears to be no good reason to keep it around.
More details please see:
https://github.com/openstack-dev/pbr/blob/master/pbr/packaging.py#L384

Change-Id: Ia4b1a59d49b445111b1ec273242fdbd1ae6f0f71
2015-12-05 13:23:27 +08: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
OpenStack Proposal Bot e7ef8fedb4 Updated from global requirements
Change-Id: If781fed45a559c71cf66d293b52db4b0fdfdb97b
2015-11-19 15:51:50 +00:00
OpenStack Proposal Bot 62d0fa2cfb Updated from global requirements
Change-Id: Ie5b421a5a7e12dda0bf65cb400985c64f61fda69
2015-11-18 20:51:02 +00:00
ChangBo Guo(gcb) fe7f065bc7 Remove python 2.6 classifier
Change-Id: I490812ea0e8a7698b4c98c6aa3775fab99defbbc
2015-11-17 15:05:37 +08:00
Jenkins 3b2fb23801 Merge "Remove python 2.6 and cleanup tox.ini" 2015-11-17 03:12:18 +00:00
ChangBo Guo(gcb) b64515963d Fix bug track URL
Change-Id: I2ed768e3f359c864eeb6aefbf943321d4b812045
2015-11-16 21:41:23 +08:00
Davanum Srinivas 4f647c7780 Remove python 2.6 and cleanup tox.ini
* Remove support for python 2.6
* Remove skipsdist : Needs to be set only if 
  sdist is expensive
* Remove usedevelop : only needed when skipsdist 
  is set to True
* Remove install_command : We can just use the 
  default, we don't need to override
* Remove setenv : We can just use the default as
  we don't need any extra environment variables
* Remove requirements.txt from deps, as this is
  already added automatically

Change-Id: I741b7cae51555bc5f8d79a018598d1dccbba4459
2015-11-16 00:47:09 +00:00
Jenkins f02cbfdf4e Merge "Use versionadded and versionchanged in doc" 2015-11-05 20:34:48 +00:00
OpenStack Proposal Bot 136fe0f838 Updated from global requirements
Change-Id: I4bd9947ffa7485787ddd04ea13e477d7a3771308
2015-10-19 23:32:08 +00:00
OpenStack Proposal Bot a8626ea9f9 Updated from global requirements
Change-Id: I370ebbed14ee09a457100e1d01044da731361abf
2015-10-16 01:00:09 +00: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 f09b9b1e4e Merge "Fix coverage configuration and execution" 2015-10-09 21:00:06 +00:00
Ronald Bradford cef5b11996 Fix coverage configuration and execution
A number of configuration errors prevent the successful creation of code
coverage. This corrects the .coveragerc source/omit setup and the tox
package name generation.

http://lists.openstack.org/pipermail/openstack-dev/2015-October/076193.html

Change-Id: If0f21e37a5d9b43c0f9491d306167d2656c137f9
2015-10-08 17:22:20 -04:00
Victor Stinner e49e812900 Add utilities for base64
Writing a code using the base64 module (of the Python standard
library) working on Python 2.7 and 3.4 requires many checks on the
input and/or output type:

* base64.b64encode() only accepts byte string: text must be
  explicitly encoded to ASCII
* base64.b64decode() returns bytes: output must be decoded from UTF-8
  when text is expected

This change adds two pairs of encode/decode functions:

* encode_as_bytes(), decode_as_bytes(): always return the result as
  a byte string
* encode_as_text(), decode_as_text(): always return the result as a
  text string

Encode functions accept text: text is encoded to UTF-8 by default,
but the encoding is configurable.

Decode functions accept text: text is decoded from ASCII.

decode_as_text() decodes the result from UTF-8 by default, but again
the encoding is configurable.


The new submodule is called "base64" to be able to replace:

    import base64

with:

    from oslo_serialization import base64

If the base64 module of the stdlib is needed, it can be imported as a
different name. Example:

    import base64 as std_base64


The encoding example:

    if isinstance(text, six.text_type):
       text = text.encode('utf-8')
    text_b64 = base64.b64encode(text)
    text_b64 = text_b64.decode('ascii')

can be replaced with:

    text_b64 = base64.encode_as_text(text)


The decoding example:

    if isinstance(encoded, six.text_type):
       encoded = encoded.decode('ascii')
    text = base64.b64decode(encoded)
    text = text.decode('utf-8')

can be replaced with:

    text = base64.decode_as_text(text)

Change-Id: Icf8df9c947bc0c5f4838508b756ed8f53efd9fc4
2015-10-01 14:32:29 +00:00