mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #5933 from tk0miya/fix_parse_eggfile_on_windows
Fix parse eggfile on windows
This commit is contained in:
commit
4144f821e1
1
CHANGES
1
CHANGES
@ -24,6 +24,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
|
||||
|
@ -11,6 +11,7 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import re
|
||||
from os import path
|
||||
from zipfile import ZipFile
|
||||
|
||||
from six import iteritems, BytesIO, StringIO
|
||||
@ -45,7 +46,7 @@ class ModuleAnalyzer(object):
|
||||
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)
|
||||
@ -54,7 +55,8 @@ class ModuleAnalyzer(object):
|
||||
@classmethod
|
||||
def for_egg(cls, filename, modname):
|
||||
# type: (unicode, unicode) -> ModuleAnalyzer
|
||||
eggpath, relpath = re.split('(?<=\\.egg)/', filename)
|
||||
SEP = re.escape(path.sep)
|
||||
eggpath, relpath = re.split('(?<=\\.egg)' + SEP, filename)
|
||||
try:
|
||||
with ZipFile(eggpath) as egg:
|
||||
code = egg.read(relpath).decode('utf-8')
|
||||
|
Loading…
Reference in New Issue
Block a user