diff options
Diffstat (limited to 'sphinx/pycode/__init__.py')
| -rw-r--r-- | sphinx/pycode/__init__.py | 23 |
1 files changed, 1 insertions, 22 deletions
diff --git a/sphinx/pycode/__init__.py b/sphinx/pycode/__init__.py index 29a62e94a..64e8bff4e 100644 --- a/sphinx/pycode/__init__.py +++ b/sphinx/pycode/__init__.py @@ -2,13 +2,11 @@ from __future__ import annotations -import re import tokenize from collections import OrderedDict from importlib import import_module from os import path from typing import TYPE_CHECKING, Any -from zipfile import ZipFile from sphinx.errors import PycodeError from sphinx.pycode.parser import Parser @@ -66,11 +64,6 @@ class ModuleAnalyzer: filename += 'w' elif not filename.lower().endswith(('.py', '.pyw')): raise PycodeError('source is not a .py file: %r' % filename) - elif ('.egg' + path.sep) in filename: - pat = '(?<=\\.egg)' + re.escape(path.sep) - eggpath, _ = re.split(pat, filename, 1) - if path.isfile(eggpath): - return filename, None if not path.isfile(filename): raise PycodeError('source file is not present: %r' % filename) @@ -91,24 +84,10 @@ class ModuleAnalyzer: obj = cls(string, modname, filename) cls.cache['file', filename] = obj except Exception as err: - if '.egg' + path.sep in filename: - obj = cls.cache['file', filename] = cls.for_egg(filename, modname) - else: - raise PycodeError('error opening %r' % filename, err) from err + raise PycodeError('error opening %r' % filename, err) from err return obj @classmethod - def for_egg(cls, filename: str, modname: str) -> ModuleAnalyzer: - SEP = re.escape(path.sep) - eggpath, relpath = re.split('(?<=\\.egg)' + SEP, filename) - try: - with ZipFile(eggpath) as egg: - code = egg.read(relpath).decode() - return cls.for_string(code, modname, filename) - except Exception as exc: - raise PycodeError('error opening %r' % filename, exc) from exc - - @classmethod def for_module(cls, modname: str) -> ModuleAnalyzer: if ('module', modname) in cls.cache: entry = cls.cache['module', modname] |
