mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
is_py3k -> is_py3
This commit is contained in:
@@ -10,9 +10,9 @@ try:
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
is_py3k = sys.hexversion >= 0x03000000
|
||||
is_py33 = sys.hexversion >= 0x03030000
|
||||
is_py26 = sys.hexversion < 0x02700000
|
||||
is_py3 = sys.version_info[0] >= 3
|
||||
is_py33 = is_py3 and sys.version_info.minor >= 3
|
||||
is_py26 = not is_py3 and sys.version_info[1] < 7
|
||||
|
||||
|
||||
def find_module_py33(string, path=None):
|
||||
@@ -82,7 +82,7 @@ try:
|
||||
except NameError:
|
||||
unicode = str
|
||||
|
||||
if is_py3k:
|
||||
if is_py3:
|
||||
utf8 = lambda s: s
|
||||
else:
|
||||
utf8 = lambda s: s.decode('utf-8')
|
||||
@@ -92,7 +92,7 @@ Decode a raw string into unicode object. Do nothing in Python 3.
|
||||
"""
|
||||
|
||||
# exec function
|
||||
if is_py3k:
|
||||
if is_py3:
|
||||
def exec_function(source, global_map):
|
||||
exec(source, global_map)
|
||||
else:
|
||||
@@ -100,7 +100,7 @@ else:
|
||||
exec source in global_map """, 'blub', 'exec'))
|
||||
|
||||
# re-raise function
|
||||
if is_py3k:
|
||||
if is_py3:
|
||||
def reraise(exception, traceback):
|
||||
raise exception.with_traceback(traceback)
|
||||
else:
|
||||
@@ -125,7 +125,7 @@ except ImportError:
|
||||
from io import StringIO
|
||||
|
||||
# hasattr function used because python
|
||||
if is_py3k:
|
||||
if is_py3:
|
||||
hasattr = hasattr
|
||||
else:
|
||||
def hasattr(obj, name):
|
||||
@@ -168,7 +168,7 @@ def u(string):
|
||||
have to cast back to a unicode (and we now that we always deal with valid
|
||||
unicode, because we check that in the beginning).
|
||||
"""
|
||||
if is_py3k:
|
||||
if is_py3:
|
||||
return str(string)
|
||||
elif not isinstance(string, unicode):
|
||||
return unicode(str(string), 'UTF-8')
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import pydoc
|
||||
import keyword
|
||||
|
||||
from jedi._compatibility import is_py3k
|
||||
from jedi._compatibility import is_py3
|
||||
from jedi import common
|
||||
from jedi.evaluate import compiled
|
||||
|
||||
@@ -11,7 +11,7 @@ except ImportError:
|
||||
# Python 2.6
|
||||
import pydoc_topics
|
||||
|
||||
if is_py3k:
|
||||
if is_py3:
|
||||
keys = keyword.kwlist
|
||||
else:
|
||||
keys = keyword.kwlist + ['None', 'False', 'True']
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from jedi._compatibility import u, encoding, is_py3k
|
||||
from jedi._compatibility import encoding, is_py3
|
||||
import inspect
|
||||
import os
|
||||
import time
|
||||
@@ -80,7 +80,7 @@ def print_to_stdout(level, str_out):
|
||||
col = Fore.RED
|
||||
else:
|
||||
col = Fore.YELLOW
|
||||
if not is_py3k:
|
||||
if not is_py3:
|
||||
str_out = str_out.encode(encoding, 'replace')
|
||||
print(col + str_out + Fore.RESET)
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ mixing in Python code, the autocompletion should work much better for builtins.
|
||||
import os
|
||||
import inspect
|
||||
|
||||
from jedi._compatibility import is_py3k, builtins
|
||||
from jedi._compatibility import is_py3, builtins
|
||||
from jedi.parser import Parser
|
||||
from jedi.parser.representation import Class
|
||||
from jedi.evaluate.helpers import FakeName
|
||||
@@ -17,7 +17,7 @@ modules = {}
|
||||
|
||||
def _load_faked_module(module):
|
||||
module_name = module.__name__
|
||||
if module_name == '__builtin__' and not is_py3k:
|
||||
if module_name == '__builtin__' and not is_py3:
|
||||
module_name = 'builtins'
|
||||
|
||||
try:
|
||||
@@ -33,7 +33,7 @@ def _load_faked_module(module):
|
||||
module = Parser(source, module_name).module
|
||||
modules[module_name] = module
|
||||
|
||||
if module_name == 'builtins' and not is_py3k:
|
||||
if module_name == 'builtins' and not is_py3:
|
||||
# There are two implementations of `open` for either python 2/3.
|
||||
# -> Rename the python2 version (`look at fake/builtins.pym`).
|
||||
open_func = search_scope(module, 'open')
|
||||
|
||||
@@ -3,7 +3,7 @@ import itertools
|
||||
from jedi import common
|
||||
from jedi import debug
|
||||
from jedi import settings
|
||||
from jedi._compatibility import use_metaclass, is_py3k, unicode
|
||||
from jedi._compatibility import use_metaclass, is_py3, unicode
|
||||
from jedi.parser import representation as pr
|
||||
from jedi.evaluate import compiled
|
||||
from jedi.evaluate import helpers
|
||||
@@ -200,7 +200,7 @@ def get_iterator_types(inputs):
|
||||
result += gen.get_index_types()
|
||||
elif isinstance(gen, Instance):
|
||||
# __iter__ returned an instance.
|
||||
name = '__next__' if is_py3k else 'next'
|
||||
name = '__next__' if is_py3 else 'next'
|
||||
try:
|
||||
result += gen.execute_subscope_by_name(name)
|
||||
except KeyError:
|
||||
|
||||
@@ -38,7 +38,7 @@ import re
|
||||
from inspect import cleandoc
|
||||
from ast import literal_eval
|
||||
|
||||
from jedi._compatibility import next, Python3Method, encoding, unicode, is_py3k
|
||||
from jedi._compatibility import next, Python3Method, encoding, unicode, is_py3
|
||||
from jedi import common
|
||||
from jedi import debug
|
||||
from jedi import cache
|
||||
@@ -122,7 +122,7 @@ class Simple(Base):
|
||||
|
||||
def __repr__(self):
|
||||
code = self.get_code().replace('\n', ' ')
|
||||
if not is_py3k:
|
||||
if not is_py3:
|
||||
code = code.encode(encoding, 'replace')
|
||||
return "<%s: %s@%s,%s>" % \
|
||||
(type(self).__name__, code, self.start_pos[0], self.start_pos[1])
|
||||
@@ -1234,7 +1234,7 @@ class Literal(StatementElement):
|
||||
return self.literal + super(Literal, self).get_code()
|
||||
|
||||
def __repr__(self):
|
||||
if is_py3k:
|
||||
if is_py3:
|
||||
s = self.literal
|
||||
else:
|
||||
s = self.literal.encode('ascii', 'replace')
|
||||
|
||||
@@ -102,7 +102,7 @@ from ast import literal_eval
|
||||
|
||||
import jedi
|
||||
from functools import reduce
|
||||
from jedi._compatibility import unicode, StringIO, is_py3k
|
||||
from jedi._compatibility import unicode, StringIO, is_py3
|
||||
|
||||
|
||||
TEST_COMPLETIONS = 0
|
||||
@@ -217,7 +217,7 @@ def collect_file_tests(lines, lines_to_execute):
|
||||
test_type = None
|
||||
for line_nr, line in enumerate(lines):
|
||||
line_nr += 1 # py2.5 doesn't know about the additional enumerate param
|
||||
if not is_py3k:
|
||||
if not is_py3:
|
||||
line = unicode(line, 'UTF-8')
|
||||
if correct:
|
||||
r = re.match('^(\d+)\s*(.*)$', correct)
|
||||
|
||||
Reference in New Issue
Block a user