Hi,

I noticed that Sphinx does not build docs if I use the autodoc feature in a 
project where the path name contains unicode characters (of course the Python 
module names only contain ASCII). This is on Fedora 10 with Python 2.5.2.

> reading sources... index Sphinx error:
> 'ascii' codec can't decode byte 0xc3 in position 17: ordinal not in range(128)
> make: *** [html] Fehler 1

This is because the 'fullname' in generate() (sphinx.ext.autodoc, l. 452) may 
be a unicode string (without unicode characters) but 'analyzer.srcname' 
contains the path name (byte string) with UTF-8 encoded characters. Therefore 
the interpolation fails:
sourcename = '%s:docstring of %s' % (analyzer.srcname, fullname)

I think the root cause of this problem is solved by my patch (actually I'm not 
sure what 'name' in l. 355 may contain, maybe it's even easier just doing 
'str(name)').

fs


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sphinx-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sphinx-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

diff -r 4a7bc747fe94 sphinx/ext/autodoc.py
--- a/sphinx/ext/autodoc.py     Wed Jan 14 19:39:42 2009 +0100
+++ b/sphinx/ext/autodoc.py     Wed Jan 14 21:12:32 2009 +0100
@@ -359,8 +359,9 @@
                       '(try placing a "module" or "currentmodule" directive in 
the '
                       'document, or giving an explicit module name)' % name)
             return
+        mod = str(mod)
         # fully-qualified name
-        fullname = mod + (objpath and '.' + '.'.join(objpath) or '')
+        fullname = str(mod + (objpath and '.' + '.'.join(objpath) or ''))
 
         # the name to put into the generated directive -- doesn't contain the 
module
         name_in_directive = '.'.join(objpath) or mod
@@ -374,7 +375,7 @@
         except (ImportError, AttributeError), err:
             self.warn('autodoc can\'t import/find %s %r, it reported error: 
"%s", '
                       'please check your spelling and sys.path' %
-                      (what, str(fullname), err))
+                      (what, fullname, err))
             return
 
         # try to also get a source code analyzer for attribute docs

Reply via email to