diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py
index 198824ee2..3142fd964 100644
--- a/sphinx/builders/html.py
+++ b/sphinx/builders/html.py
@@ -53,20 +53,16 @@ INVENTORY_FILENAME = 'objects.inv'
LAST_BUILD_FILENAME = 'last_build'
-def get_object_hash(obj):
+def get_stable_hash(obj):
"""
- In python3.3, unicode(dict_instance) retun another string per process.
- get_object_hash(dict_instance) return same hash for same dict_instance.
+ Return a stable hash for a Python data structure. We can't just use
+ the md5 of str(obj) since for example dictionary items are enumerated
+ in unpredictable order due to hash randomization in newer Pythons.
"""
if isinstance(obj, dict):
- return get_object_hash(list(obj.items()))
-
+ return get_stable_hash(list(obj.items()))
elif isinstance(obj, (list, tuple)):
- obj = sorted(get_object_hash(o) for o in obj)
-
- else: # int or other objects
- pass
-
+ obj = sorted(get_stable_hash(o) for o in obj)
return md5(unicode(obj).encode('utf8')).hexdigest()
@@ -173,8 +169,8 @@ class StandaloneHTMLBuilder(Builder):
cfgdict = dict((name, self.config[name])
for (name, desc) in self.config.values.iteritems()
if desc[1] == 'html')
- self.config_hash = get_object_hash(cfgdict)
- self.tags_hash = get_object_hash(sorted(self.tags))
+ self.config_hash = get_stable_hash(cfgdict)
+ self.tags_hash = get_stable_hash(sorted(self.tags))
old_config_hash = old_tags_hash = ''
try:
fp = open(path.join(self.outdir, '.buildinfo'))