diff --git a/CHANGES b/CHANGES index 89bef3c3d..dca24902b 100644 --- a/CHANGES +++ b/CHANGES @@ -209,6 +209,7 @@ Bugs fixed * #5755: C++, fix duplicate declaration error on function templates with constraints in the return type. * C++, parse unary right fold expressions and binary fold expressions. +* pycode could not handle egg files on windows * #5928: KeyError: 'DOCUTILSCONFIG' when running build Testing diff --git a/sphinx/pycode/__init__.py b/sphinx/pycode/__init__.py index 890cf89bd..5d59bc310 100644 --- a/sphinx/pycode/__init__.py +++ b/sphinx/pycode/__init__.py @@ -10,6 +10,7 @@ import re from io import StringIO +from os import path from zipfile import ZipFile from sphinx.errors import PycodeError @@ -40,7 +41,7 @@ class ModuleAnalyzer: obj = cls(f, modname, filename) cls.cache['file', filename] = obj except Exception as err: - if '.egg/' in filename: + if '.egg' + path.sep in filename: obj = cls.cache['file', filename] = cls.for_egg(filename, modname) else: raise PycodeError('error opening %r' % filename, err) @@ -48,8 +49,14 @@ class ModuleAnalyzer: @classmethod def for_egg(cls, filename, modname): +<<<<<<< HEAD # type: (str, str) -> ModuleAnalyzer eggpath, relpath = re.split('(?<=\\.egg)/', filename) +======= + # type: (unicode, unicode) -> ModuleAnalyzer + SEP = re.escape(path.sep) + eggpath, relpath = re.split('(?<=\\.egg)' + SEP, filename) +>>>>>>> 1.8 try: with ZipFile(eggpath) as egg: code = egg.read(relpath).decode()