mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-19 12:01:12 +08:00
python 2.5 compatibility
This commit is contained in:
@@ -2,9 +2,12 @@
|
|||||||
This is a compatibility module, to make it possible to use jedi also with older
|
This is a compatibility module, to make it possible to use jedi also with older
|
||||||
python versions.
|
python versions.
|
||||||
"""
|
"""
|
||||||
|
import sys
|
||||||
|
|
||||||
def is_py3k():
|
def is_py3k():
|
||||||
return sys.hexversion >= 0x03000000
|
return sys.hexversion >= 0x03000000
|
||||||
import sys
|
|
||||||
|
is_py25 = sys.hexversion < 0x02060000
|
||||||
|
|
||||||
# next was defined in python 2.6, in python 3 obj.next won't be possible
|
# next was defined in python 2.6, in python 3 obj.next won't be possible
|
||||||
# anymore
|
# anymore
|
||||||
|
|||||||
@@ -7,8 +7,12 @@ import pydoc
|
|||||||
try:
|
try:
|
||||||
from pydoc_data import topics as pydoc_topics
|
from pydoc_data import topics as pydoc_topics
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# Python 2.5/2.6
|
# Python 2.6
|
||||||
|
try:
|
||||||
import pydoc_topics
|
import pydoc_topics
|
||||||
|
except ImportError:
|
||||||
|
# Python 2.5
|
||||||
|
pydoc_topics = None
|
||||||
|
|
||||||
if is_py3k():
|
if is_py3k():
|
||||||
keys = keyword.kwlist
|
keys = keyword.kwlist
|
||||||
@@ -63,4 +67,4 @@ def imitate_pydoc(string):
|
|||||||
except TypeError:
|
except TypeError:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
return pydoc_topics.topics[label]
|
return pydoc_topics.topics[label] if pydoc_topics else ''
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import unittest
|
|||||||
os.chdir(os.path.dirname(os.path.abspath(__file__)) + '/..')
|
os.chdir(os.path.dirname(os.path.abspath(__file__)) + '/..')
|
||||||
sys.path.append('.')
|
sys.path.append('.')
|
||||||
|
|
||||||
|
from _compatibility import is_py25
|
||||||
import functions
|
import functions
|
||||||
#functions.set_debug_function(functions.debug.print_to_stdout)
|
#functions.set_debug_function(functions.debug.print_to_stdout)
|
||||||
|
|
||||||
@@ -56,6 +57,7 @@ class TestRegression(unittest.TestCase):
|
|||||||
def test_keyword_doc(self):
|
def test_keyword_doc(self):
|
||||||
r = list(self.get_def("or", (1,1)))
|
r = list(self.get_def("or", (1,1)))
|
||||||
assert len(r) == 1
|
assert len(r) == 1
|
||||||
|
if not is_py25:
|
||||||
assert len(r[0].doc) > 100
|
assert len(r[0].doc) > 100
|
||||||
|
|
||||||
r = list(self.get_def("asfdasfd", (1,1)))
|
r = list(self.get_def("asfdasfd", (1,1)))
|
||||||
@@ -64,6 +66,7 @@ class TestRegression(unittest.TestCase):
|
|||||||
def test_operator_doc(self):
|
def test_operator_doc(self):
|
||||||
r = list(self.get_def("a == b", (1,3)))
|
r = list(self.get_def("a == b", (1,3)))
|
||||||
assert len(r) == 1
|
assert len(r) == 1
|
||||||
|
if not is_py25:
|
||||||
assert len(r[0].doc) > 100
|
assert len(r[0].doc) > 100
|
||||||
|
|
||||||
def test_get_definition_at_zero(self):
|
def test_get_definition_at_zero(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user