Merge bugfix from 0.5.

This commit is contained in:
Georg Brandl 2008-11-30 20:57:48 +01:00
commit b572cf2504
3 changed files with 32 additions and 6 deletions

View File

@ -21,6 +21,12 @@ New features added
command line.
Release 0.5.1 (in development)
==============================
* Don't crash on empty index entries, only emit a warning.
Release 0.5 (Nov 23, 2008) -- Birthday release!
===============================================

View File

@ -205,7 +205,10 @@ def index_directive(name, arguments, options, content, lineno,
# shorthand notation for single entries
else:
for value in entry.split(','):
ne.append(('single', value.strip(), targetid, value.strip()))
value = value.strip()
if not value:
continue
ne.append(('single', value, targetid, value))
return [indexnode, targetnode]
index_directive.arguments = (1, 0, 1)

View File

@ -1137,25 +1137,42 @@ class BuildEnvironment:
pass
for fn, entries in self.indexentries.iteritems():
# new entry types must be listed in directives.py!
# new entry types must be listed in directives/other.py!
for type, string, tid, alias in entries:
if type == 'single':
try:
entry, subentry = string.split(';', 1)
except ValueError:
entry, subentry = string, ''
if not entry:
self.warn(fn, 'invalid index entry %r' % string)
continue
add_entry(entry.strip(), subentry.strip())
elif type == 'pair':
first, second = map(lambda x: x.strip(), string.split(';', 1))
try:
first, second = map(lambda x: x.strip(),
string.split(';', 1))
if not first or not second:
raise ValueError
except ValueError:
self.warn(fn, 'invalid pair index entry %r' % string)
continue
add_entry(first, second)
add_entry(second, first)
elif type == 'triple':
first, second, third = map(lambda x: x.strip(), string.split(';', 2))
try:
first, second, third = map(lambda x: x.strip(),
string.split(';', 2))
if not first or not second or not third:
raise ValueError
except ValueError:
self.warn(fn, 'invalid triple index entry %r' % string)
continue
add_entry(first, second+' '+third)
add_entry(second, third+', '+first)
add_entry(third, first+' '+second)
else:
self.warn(fn, "unknown index entry type %r" % type)
self.warn(fn, 'unknown index entry type %r' % type)
newlist = new.items()
newlist.sort(key=lambda t: t[0].lower())