Closed lukpueh closed 7 years ago
Long term, I don't want to add the canonicaljson lib as a dependency, so I'm going to update the code that generates JSON to produce canonical json. TUF does something similar (You can find it here in tuf/client/repository_lib.py).
For now, I'll just use canonicaljson as added in this PR.
This is a rather huge PR but it has a lot of similar changes all over the place. The changes are thematically grouped in separate commits:
six
to provide consistency over renamed packages (getcwd
,xrange
,xmlrpc
)print_function
pseudo module to provide fully-fledgedprint
functionsunicode_literals
pseudo module to make all string literals unicode without explicit markup (likeu'Hellü'
)open
fromio
instead of builtin to provide consistency in terms of functionalitycanonicaljson
to utf-8 encode JSON strings and write the to disk in binary mode. They can be read in text mode with the utf-8 encoding specified.setup.py
Tested on Python 2.7.10 and Python 3.5.1 using demo.
Note on
__future__
: Python's migration guide recommends to always add a certain set of__future__
import satements to new Python modules. I only added them where needed. Please keep in mind that they might need to be added as the code changes.