Merge pull request #5442 from tk0miya/5437_autodoc_crashed_for_egg_packages

Fix #5437: autodoc: crashed on modules importing eggs
This commit is contained in:
Takeshi KOMIYA 2018-09-18 22:49:37 +09:00 committed by GitHub
commit 5d509d69ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -22,6 +22,7 @@ Bugs fixed
* #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
* #4911: add latexpdf to make.bat for non make-mode * #4911: add latexpdf to make.bat for non make-mode
* #5436: Autodoc does not work with enum subclasses with properties/methods * #5436: Autodoc does not work with enum subclasses with properties/methods
* #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