diff options
author | Dmitry Shachnev <mitya57@gmail.com> | 2015-01-28 19:28:53 +0300 |
---|---|---|
committer | Dmitry Shachnev <mitya57@gmail.com> | 2015-01-28 21:24:36 +0300 |
commit | d24bd73d0ce8071459a1056691a1934e1ca12194 (patch) | |
tree | d587d76fefb266534f2066f6afa9379a4f484d79 /sphinx/util/jsdump.py | |
parent | 81ffb36772820cf2a0123348ce04df01bddd2229 (diff) | |
download | sphinx-git-d24bd73d0ce8071459a1056691a1934e1ca12194.tar.gz |
Remove non-determinism
To enable packages using Sphinx to build reproducibly, its output
needs to be the same from one build to another.
Its output now strips memory references such as:
<__main__.A at 0x7f68cb685710>
In addition, various generated files (objects.inv, searchindex.js,
translations) are now written with their keys in a determinstic order.
Based on a patch by Chris Lamb <lamby@debian.org>.
Diffstat (limited to 'sphinx/util/jsdump.py')
-rw-r--r-- | sphinx/util/jsdump.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sphinx/util/jsdump.py b/sphinx/util/jsdump.py index e75648a6b..49813672d 100644 --- a/sphinx/util/jsdump.py +++ b/sphinx/util/jsdump.py @@ -89,11 +89,13 @@ def dumps(obj, key=False): elif isinstance(obj, integer_types + (float,)): return str(obj) elif isinstance(obj, dict): - return '{%s}' % ','.join('%s:%s' % ( + return '{%s}' % ','.join(sorted('%s:%s' % ( dumps(key, True), dumps(value) - ) for key, value in iteritems(obj)) - elif isinstance(obj, (tuple, list, set)): + ) for key, value in iteritems(obj))) + elif isinstance(obj, set): + return '[%s]' % ','.join(sorted(dumps(x) for x in obj)) + elif isinstance(obj, (tuple, list)): return '[%s]' % ','.join(dumps(x) for x in obj) elif isinstance(obj, string_types): return encode_string(obj) |