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/95749 /git.openstack. org/cgit/ openstack/ oslo-incubator/ commit/ ?id=1b9018859fa 3b420d01ed191b9 16476db6eb9182
Committed: https:/
Submitter: Jenkins
Branch: stable/icehouse
commit 1b9018859fa3b42 0d01ed191b91647 6db6eb9182
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: unit/test_ jsonutils. py
tests/
Change-Id: Ic815ca3df94c33 edec9104172048b 2cd94b92e3f a22c70842e7c127 da21c63b8b)
(cherry picked from commit 18f2bc1bf080b41