mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
fix #1008: can't get correct source code filename because all modules have '__loader__' attribute at Python-3.3.
This commit is contained in:
parent
2d238baa57
commit
c1145e65ba
@ -197,14 +197,14 @@ def get_module_source(modname):
|
||||
except Exception, err:
|
||||
raise PycodeError('error importing %r' % modname, err)
|
||||
mod = sys.modules[modname]
|
||||
if hasattr(mod, '__loader__'):
|
||||
try:
|
||||
source = mod.__loader__.get_source(modname)
|
||||
except Exception, err:
|
||||
raise PycodeError('error getting source for %r' % modname, err)
|
||||
return 'string', source
|
||||
filename = getattr(mod, '__file__', None)
|
||||
if filename is None:
|
||||
if hasattr(mod, '__loader__'):
|
||||
try:
|
||||
source = mod.__loader__.get_source(modname)
|
||||
except Exception, err:
|
||||
raise PycodeError('error getting source for %r' % modname, err)
|
||||
return 'string', source
|
||||
raise PycodeError('no source found for module %r' % modname)
|
||||
filename = path.normpath(path.abspath(filename))
|
||||
lfilename = filename.lower()
|
||||
|
Loading…
Reference in New Issue
Block a user