mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
fixed a bug that made it impossible to load two cbuiltins from the same directory / 2.5 compatibility
This commit is contained in:
23
builtin.py
23
builtin.py
@@ -81,8 +81,6 @@ class Parser(CachedModule):
|
|||||||
if not name:
|
if not name:
|
||||||
name = os.path.basename(path)
|
name = os.path.basename(path)
|
||||||
name = name.rpartition('.')[0] # cut file type (normally .so)
|
name = name.rpartition('.')[0] # cut file type (normally .so)
|
||||||
path = os.path.dirname(path)
|
|
||||||
#print self.name, self.path
|
|
||||||
super(Parser, self).__init__(path=path, name=name)
|
super(Parser, self).__init__(path=path, name=name)
|
||||||
|
|
||||||
self.sys_path = sys_path
|
self.sys_path = sys_path
|
||||||
@@ -138,23 +136,22 @@ class Parser(CachedModule):
|
|||||||
# remove class line
|
# remove class line
|
||||||
c = re.sub(r'^[^\n]+', '', code_block)
|
c = re.sub(r'^[^\n]+', '', code_block)
|
||||||
# remove whitespace
|
# remove whitespace
|
||||||
c = re.sub(r'^[ ]{4}', '', c, flags=re.MULTILINE)
|
c = re.compile(r'^[ ]{4}', re.MULTILINE).sub('', c)
|
||||||
|
|
||||||
funcs[name] = process_code(c)
|
funcs[name] = process_code(c)
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
return funcs
|
return funcs
|
||||||
|
|
||||||
if not self.path:
|
try:
|
||||||
try:
|
name = self.name
|
||||||
name = self.name
|
if name == '__builtin__' and sys.hexversion < 0x03000000:
|
||||||
if name == '__builtin__' and sys.hexversion < 0x03000000:
|
name = 'builtins'
|
||||||
name = 'builtins'
|
f = open(os.path.sep.join(['mixin', name]) + '.py')
|
||||||
f = open(os.path.sep.join(['mixin', name]) + '.py')
|
except IOError:
|
||||||
except IOError:
|
return {}
|
||||||
return {}
|
else:
|
||||||
else:
|
return process_code(f.read())
|
||||||
return process_code(f.read())
|
|
||||||
|
|
||||||
def _generate_code(self, scope, mixin_funcs, depth=0):
|
def _generate_code(self, scope, mixin_funcs, depth=0):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -957,6 +957,9 @@ class PyFuzzyParser(object):
|
|||||||
# delete code again, only the parser needs it
|
# delete code again, only the parser needs it
|
||||||
del self.code
|
del self.code
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "<%s: %s>" % (self.__class__.__name__, self.top)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def line_nr(self):
|
def line_nr(self):
|
||||||
return self._line_of_tokenize_restart + self._tokenize_line_nr
|
return self._line_of_tokenize_restart + self._tokenize_line_nr
|
||||||
|
|||||||
11
test/run.py
11
test/run.py
@@ -10,6 +10,11 @@ import functions
|
|||||||
from _compatibility import unicode, BytesIO
|
from _compatibility import unicode, BytesIO
|
||||||
|
|
||||||
only_line = int(sys.argv[2]) if len(sys.argv) > 2 else None
|
only_line = int(sys.argv[2]) if len(sys.argv) > 2 else None
|
||||||
|
if only_line is not None:
|
||||||
|
import debug
|
||||||
|
debug.debug_function = \
|
||||||
|
functions.debug.print_to_stdout
|
||||||
|
debug.ignored_modules = ['parsing', 'builtin']
|
||||||
#functions.set_debug_function(functions.debug.print_to_stdout)
|
#functions.set_debug_function(functions.debug.print_to_stdout)
|
||||||
|
|
||||||
def run_completion_test(correct, source, line_nr, line):
|
def run_completion_test(correct, source, line_nr, line):
|
||||||
@@ -109,12 +114,8 @@ def run_test(source):
|
|||||||
correct = None
|
correct = None
|
||||||
else:
|
else:
|
||||||
# reset the test, if only one specific test is wanted
|
# reset the test, if only one specific test is wanted
|
||||||
if only_line is not None and line_nr != only_line:
|
if only_line and line_nr != only_line:
|
||||||
correct = None
|
correct = None
|
||||||
import debug
|
|
||||||
debug.debug_function = \
|
|
||||||
functions.debug.print_to_stdout
|
|
||||||
debug.ignored_modules = ['parsing', 'builtin']
|
|
||||||
return tests, fails
|
return tests, fails
|
||||||
|
|
||||||
# completion tests:
|
# completion tests:
|
||||||
|
|||||||
Reference in New Issue
Block a user