diff options
author | Georg Brandl <georg@python.org> | 2013-01-19 21:15:11 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2013-01-19 21:15:11 +0100 |
commit | fc197dcfdc52fa695a40ab58416cc22b99d56335 (patch) | |
tree | cbf22b18db0124e19da6a552656a732ab3fe4c48 | |
parent | f913a666028a7ef57ac0c5e9d2fe36c40d64ea6b (diff) | |
parent | af5fcda7d72a6e706575878c3bb92d31ab3e7c39 (diff) | |
download | sphinx-fc197dcfdc52fa695a40ab58416cc22b99d56335.tar.gz |
merge default heads
-rw-r--r-- | sphinx/builders/devhelp.py | 1 | ||||
-rw-r--r-- | sphinx/builders/html.py | 22 |
2 files changed, 20 insertions, 3 deletions
diff --git a/sphinx/builders/devhelp.py b/sphinx/builders/devhelp.py index 28be94ca..81d2e6ce 100644 --- a/sphinx/builders/devhelp.py +++ b/sphinx/builders/devhelp.py @@ -10,6 +10,7 @@ :copyright: Copyright 2007-2013 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. """ +from __future__ import absolute_import import re from os import path diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py index 573bb9b2..1d1dfa79 100644 --- a/sphinx/builders/html.py +++ b/sphinx/builders/html.py @@ -53,6 +53,23 @@ INVENTORY_FILENAME = 'objects.inv' LAST_BUILD_FILENAME = 'last_build' +def get_object_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. + """ + if isinstance(obj, dict): + return get_object_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 + + return md5(unicode(obj).encode('utf8')).hexdigest() + + class StandaloneHTMLBuilder(Builder): """ Builds standalone HTML docs. @@ -156,9 +173,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 = md5(unicode(cfgdict).encode('utf-8')).hexdigest() - self.tags_hash = md5(unicode(sorted(self.tags)).encode('utf-8')) \ - .hexdigest() + self.config_hash = get_object_hash(cfgdict) + self.tags_hash = get_object_hash(sorted(self.tags)) old_config_hash = old_tags_hash = '' try: fp = open(path.join(self.outdir, '.buildinfo')) |