Enforce unicode json output for jsonutils.load[s]()
simplejson module applies some optimizations on ASCII-only unicode
strings which result in non-unicode json output. See details at [1]
and [2]. To make sure we always return consistent json output no
matter which json implementation is used, we should explicitly convert
the input for json.load[s]() to unicode.
If user wants to pass a file object of non UTF-8 encoding to
json.load[s](), she must also specify this encoding as an argument. To
support this scenario too, we've added 'encoding' argument to
jsonutils.load[s]() implementation.
Made all present JSON tests to run on both supported json library
implementations.
Added explicit dependency for simplejson to be able to test different
implementations in unit tests. Distributors still running Python 2.6
are recommended but not required to install simplejson.
Reviewed: https:/ /review. openstack. org/95753 /git.openstack. org/cgit/ openstack/ oslo-incubator/ commit/ ?id=6a290f5dedc c00538c12e7b1e3 a2374ea48919c0
Committed: https:/
Submitter: Jenkins
Branch: stable/havana
commit 6a290f5dedcc005 38c12e7b1e3a237 4ea48919c0
Author: Ihar Hrachyshka <email address hidden>
Date: Wed Apr 30 14:53:15 2014 +0200
Enforce unicode json output for jsonutils.load[s]()
simplejson module applies some optimizations on ASCII-only unicode
strings which result in non-unicode json output. See details at [1]
and [2]. To make sure we always return consistent json output no
matter which json implementation is used, we should explicitly convert
the input for json.load[s]() to unicode.
If user wants to pass a file object of non UTF-8 encoding to load[s] () implementation.
json.load[s](), she must also specify this encoding as an argument. To
support this scenario too, we've added 'encoding' argument to
jsonutils.
Made all present JSON tests to run on both supported json library ions.
implementat
Added explicit dependency for simplejson to be able to test different
implementations in unit tests. Distributors still running Python 2.6
are recommended but not required to install simplejson.
Related-Bug: 1314129
[1]: https:/ /code.djangopro ject.com/ ticket/ 11742 /code.google. com/p/simplejso n/issues/ detail? id=40
[2]: https:/
Conflicts: requirements- py3.txt unit/test_ jsonutils. py
test-
tests/
Change-Id: Ic815ca3df94c33 edec9104172048b 2cd94b92e3f a22c70842e7c127 da21c63b8b)
(cherry picked from commit 18f2bc1bf080b41