From d24bd73d0ce8071459a1056691a1934e1ca12194 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Wed, 28 Jan 2015 19:28:53 +0300 Subject: 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 . --- sphinx/util/jsdump.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'sphinx/util/jsdump.py') 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) -- cgit v1.2.1