diff --git a/CHANGES b/CHANGES index f657ae9ab..a2e93b298 100644 --- a/CHANGES +++ b/CHANGES @@ -22,6 +22,7 @@ Bugs fixed * #5417: Sphinx fails to build with syntax error in Python 2.7.5 * #4911: add latexpdf to make.bat for non make-mode * #5436: Autodoc does not work with enum subclasses with properties/methods +* #5437: autodoc: crashed on modules importing eggs Testing -------- diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py index 0c0c22c9c..2da685a97 100644 --- a/sphinx/util/__init__.py +++ b/sphinx/util/__init__.py @@ -314,8 +314,9 @@ def get_module_source(modname): filename += 'w' elif not (lfilename.endswith('.py') or lfilename.endswith('.pyw')): raise PycodeError('source is not a .py file: %r' % filename) - elif '.egg' in filename: - eggpath, _ = re.split('(?<=\\.egg)/', filename) + elif ('.egg' + os.path.sep) in filename: + pat = '(?<=\\.egg)' + re.escape(os.path.sep) + eggpath, _ = re.split(pat, filename, 1) if path.isfile(eggpath): return 'file', filename