mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
#426: Fix encoding issues when saving/loading intersphinx inventories.
This commit is contained in:
parent
7e7593c4dd
commit
0d4c3a31b6
@ -738,7 +738,7 @@ class StandaloneHTMLBuilder(Builder):
|
||||
try:
|
||||
f.write('# Sphinx inventory version 2\n')
|
||||
f.write('# Project: %s\n' % self.config.project.encode('utf-8'))
|
||||
f.write('# Version: %s\n' % self.config.version)
|
||||
f.write('# Version: %s\n' % self.config.version.encode('utf-8'))
|
||||
f.write('# The remainder of this file is compressed using zlib.\n')
|
||||
compressor = zlib.compressobj(9)
|
||||
for domainname, domain in self.env.domains.iteritems():
|
||||
@ -749,10 +749,13 @@ class StandaloneHTMLBuilder(Builder):
|
||||
anchor = anchor[:-len(name)] + '$'
|
||||
uri = self.get_target_uri(docname) + '#' + anchor
|
||||
if dispname == name:
|
||||
dispname = '-'
|
||||
dispname = u'-'
|
||||
f.write(compressor.compress(
|
||||
'%s %s:%s %s %s %s\n' % (name, domainname, type, prio,
|
||||
uri, dispname)))
|
||||
'%s %s:%s %s %s %s\n' % (name.encode('utf-8'),
|
||||
domainname.encode('utf-8'),
|
||||
type.encode('utf-8'), prio,
|
||||
uri.encode('utf-8'),
|
||||
dispname.encode('utf-8'))))
|
||||
f.write(compressor.flush())
|
||||
finally:
|
||||
f.close()
|
||||
|
@ -67,7 +67,7 @@ def read_inventory_v2(f, uri, join, bufsize=16*1024):
|
||||
line = f.readline()
|
||||
projname = line.rstrip()[11:].decode('utf-8')
|
||||
line = f.readline()
|
||||
version = line.rstrip()[11:]
|
||||
version = line.rstrip()[11:].decode('utf-8')
|
||||
line = f.readline()
|
||||
if 'zlib' not in line:
|
||||
raise ValueError
|
||||
@ -84,14 +84,14 @@ def read_inventory_v2(f, uri, join, bufsize=16*1024):
|
||||
buf += chunk
|
||||
lineend = buf.find('\n')
|
||||
while lineend != -1:
|
||||
yield buf[:lineend]
|
||||
yield buf[:lineend].decode('utf-8')
|
||||
buf = buf[lineend+1:]
|
||||
lineend = buf.find('\n')
|
||||
assert not buf
|
||||
|
||||
for line in split_lines(read_chunks()):
|
||||
name, type, prio, location, dispname = line.rstrip().split(None, 4)
|
||||
if location.endswith('$'):
|
||||
if location.endswith(u'$'):
|
||||
location = location[:-1] + name
|
||||
location = join(uri, location)
|
||||
invdata.setdefault(type, {})[name] = (projname, version,
|
||||
|
@ -246,6 +246,8 @@ Invalid index markup...
|
||||
keyword:
|
||||
|
||||
|
||||
.. _ölabel:
|
||||
|
||||
Ö... Some strange characters
|
||||
----------------------------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user