mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix loading JS searchindex data in Py3k.
This commit is contained in:
@@ -614,7 +614,11 @@ class StandaloneHTMLBuilder(Builder):
|
||||
def load_indexer(self, docnames):
|
||||
keep = set(self.env.all_docs) - set(docnames)
|
||||
try:
|
||||
f = open(path.join(self.outdir, self.searchindex_filename), 'rb')
|
||||
searchindexfn = path.join(self.outdir, self.searchindex_filename)
|
||||
if self.indexer_dumps_unicode:
|
||||
f = codecs.open(searchindexfn, 'r', encoding='utf-8')
|
||||
else:
|
||||
f = open(searchindexfn, 'rb')
|
||||
try:
|
||||
self.indexer.load(f, self.indexer_format)
|
||||
finally:
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
import re
|
||||
|
||||
from sphinx.util.pycompat import u
|
||||
|
||||
_str_re = re.compile(r'"(\\\\|\\"|[^"])*"')
|
||||
_int_re = re.compile(r'\d+')
|
||||
_name_re = re.compile(r'[a-zA-Z]\w*')
|
||||
@@ -50,7 +52,7 @@ def encode_string(s):
|
||||
return '"' + str(ESCAPE_ASCII.sub(replace, s)) + '"'
|
||||
|
||||
def decode_string(s):
|
||||
return ESCAPED.sub(lambda m: eval('u"'+m.group()+'"'), s)
|
||||
return ESCAPED.sub(lambda m: eval(u + '"' + m.group() + '"'), s)
|
||||
|
||||
|
||||
reswords = set("""\
|
||||
|
||||
@@ -23,6 +23,8 @@ if sys.version_info >= (3, 0):
|
||||
def b(s):
|
||||
return s.encode('utf-8')
|
||||
bytes = bytes
|
||||
# prefix for Unicode strings
|
||||
u = ''
|
||||
# support for running 2to3 over config files
|
||||
def convert_with_2to3(filepath):
|
||||
from lib2to3.refactor import RefactoringTool, get_fixers_from_package
|
||||
@@ -45,6 +47,7 @@ else:
|
||||
class_types = (type, ClassType)
|
||||
b = str
|
||||
bytes = str
|
||||
u = 'u'
|
||||
# no need to refactor on 2.x versions
|
||||
convert_with_2to3 = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user