#426: Fix encoding issues when saving/loading intersphinx inventories.

This commit is contained in:
Georg Brandl 2010-05-26 19:51:09 +02:00
parent 7e7593c4dd
commit 0d4c3a31b6
3 changed files with 12 additions and 7 deletions

View File

@ -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()

View File

@ -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,

View File

@ -246,6 +246,8 @@ Invalid index markup...
keyword:
.. _ölabel:
Ö... Some strange characters
----------------------------