Fix #5437: autodoc: crashed on modules importing eggs

This commit is contained in:
Takeshi KOMIYA 2018-09-16 16:40:30 +09:00
parent 914d93a9e1
commit e7811f0292
2 changed files with 4 additions and 2 deletions

View File

@ -20,6 +20,7 @@ Bugs fixed
* #5421: autodoc emits deprecation warning for :confval:`autodoc_default_flags` * #5421: autodoc emits deprecation warning for :confval:`autodoc_default_flags`
* #5422: lambda object causes PicklingError on storing environment * #5422: lambda object causes PicklingError on storing environment
* #5417: Sphinx fails to build with syntax error in Python 2.7.5 * #5417: Sphinx fails to build with syntax error in Python 2.7.5
* #5437: autodoc: crashed on modules importing eggs
Testing Testing
-------- --------

View File

@ -314,8 +314,9 @@ def get_module_source(modname):
filename += 'w' filename += 'w'
elif not (lfilename.endswith('.py') or lfilename.endswith('.pyw')): elif not (lfilename.endswith('.py') or lfilename.endswith('.pyw')):
raise PycodeError('source is not a .py file: %r' % filename) raise PycodeError('source is not a .py file: %r' % filename)
elif '.egg' in filename: elif ('.egg' + os.path.sep) in filename:
eggpath, _ = re.split('(?<=\\.egg)/', filename) pat = '(?<=\\.egg)' + re.escape(os.path.sep)
eggpath, _ = re.split(pat, filename, 1)
if path.isfile(eggpath): if path.isfile(eggpath):
return 'file', filename return 'file', filename