Prevent encoding errors when filenames are non-ASCII.

This commit is contained in:
Georg Brandl 2009-01-22 20:12:40 +01:00
parent bb291e5045
commit 0dd23c2dc1

View File

@ -449,7 +449,10 @@ class RstGenerator(object):
# add content from attribute documentation # add content from attribute documentation
if analyzer: if analyzer:
sourcename = '%s:docstring of %s' % (analyzer.srcname, fullname) # prevent encoding errors when the file name is non-ASCII
srcname = unicode(analyzer.srcname,
sys.getfilesystemencoding(), 'replace')
sourcename = u'%s:docstring of %s' % (srcname, fullname)
attr_docs = analyzer.find_attr_docs() attr_docs = analyzer.find_attr_docs()
if what in ('data', 'attribute'): if what in ('data', 'attribute'):
key = ('.'.join(objpath[:-1]), objpath[-1]) key = ('.'.join(objpath[:-1]), objpath[-1])
@ -460,7 +463,7 @@ class RstGenerator(object):
fullname, todoc)): fullname, todoc)):
self.result.append(indent + line, sourcename, i) self.result.append(indent + line, sourcename, i)
else: else:
sourcename = 'docstring of %s' % fullname sourcename = u'docstring of %s' % fullname
attr_docs = {} attr_docs = {}
# add content from docstrings # add content from docstrings