~ubuntu-branches/ubuntu/raring/sphinx/raring

« back to all changes in this revision

Viewing changes to sphinx/util/__init__.py

  • Committer: Package Import Robot
  • Author(s): Dmitry Shachnev
  • Date: 2012-11-01 21:39:16 UTC
  • Revision ID: package-import@ubuntu.com-20121101213916-g2flnuhyhqrcyx75
Tags: 1.1.3+dfsg-4ubuntu5
* Build-depend on python3-all instead of python3.
* debian/patches/support_python_3.3:
  Fix various testsuite failures with Python 3.3 (LP: #1070336).
* Update Homepage field.

Show diffs side-by-side

added added

removed removed

Lines of Context:
197
197
        except Exception, err:
198
198
            raise PycodeError('error importing %r' % modname, err)
199
199
    mod = sys.modules[modname]
200
 
    if hasattr(mod, '__loader__'):
201
 
        try:
202
 
            source = mod.__loader__.get_source(modname)
 
200
    filename = getattr(mod, '__file__', None)
 
201
    loader = getattr(mod, '__loader__', None)
 
202
    if loader and getattr(loader, 'get_filename', None):
 
203
        try:
 
204
            filename = loader.get_filename(modname)
 
205
        except Exception, err:
 
206
            raise PycodeError('error getting filename for %r' % filename, err)
 
207
    if filename is None and loader:
 
208
        try:
 
209
            return 'string', loader.get_source(modname)
203
210
        except Exception, err:
204
211
            raise PycodeError('error getting source for %r' % modname, err)
205
 
        return 'string', source
206
 
    filename = getattr(mod, '__file__', None)
207
212
    if filename is None:
208
213
        raise PycodeError('no source found for module %r' % modname)
209
214
    filename = path.normpath(path.abspath(filename))