forked from VimPlug/jedi
py3.0, py3.1 and py32 don't support unicode literals. Support those.
This commit is contained in:
@@ -5,6 +5,7 @@ created. Clearly there is huge need to use conforming syntax.
|
|||||||
import sys
|
import sys
|
||||||
import imp
|
import imp
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
try:
|
try:
|
||||||
import importlib
|
import importlib
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@@ -180,3 +181,15 @@ try:
|
|||||||
import builtins # module name in python 3
|
import builtins # module name in python 3
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import __builtin__ as builtins
|
import __builtin__ as builtins
|
||||||
|
|
||||||
|
|
||||||
|
import ast
|
||||||
|
|
||||||
|
|
||||||
|
def literal_eval(string):
|
||||||
|
# py3.0, py3.1 and py32 don't support unicode literals. Support those, I
|
||||||
|
# don't want to write two versions of the tokenizer.
|
||||||
|
if is_py3 and sys.version_info.minor < 3:
|
||||||
|
if re.match('[uU][\'"]', string):
|
||||||
|
string = string[1:]
|
||||||
|
return ast.literal_eval(string)
|
||||||
|
|||||||
@@ -187,7 +187,6 @@ def calculate(evaluator, left_result, operator, right_result):
|
|||||||
result = (left_result or []) + (right_result or [])
|
result = (left_result or []) + (right_result or [])
|
||||||
for i, r in enumerate(result):
|
for i, r in enumerate(result):
|
||||||
if _is_number(r) or _is_string(r):
|
if _is_number(r) or _is_string(r):
|
||||||
print r, left_result, right_result
|
|
||||||
# Literals are only valid as long as the operations are
|
# Literals are only valid as long as the operations are
|
||||||
# correct. Otherwise add a value-free instance.
|
# correct. Otherwise add a value-free instance.
|
||||||
cls = CompiledObject(type(r.obj), builtin)
|
cls = CompiledObject(type(r.obj), builtin)
|
||||||
|
|||||||
@@ -37,9 +37,9 @@ See also :attr:`Scope.subscopes` and :attr:`Scope.statements`.
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from inspect import cleandoc
|
from inspect import cleandoc
|
||||||
from ast import literal_eval
|
|
||||||
|
|
||||||
from jedi._compatibility import next, Python3Method, encoding, unicode, is_py3, u
|
from jedi._compatibility import (next, Python3Method, encoding, unicode,
|
||||||
|
is_py3, u, literal_eval)
|
||||||
from jedi import common
|
from jedi import common
|
||||||
from jedi import debug
|
from jedi import debug
|
||||||
from jedi import cache
|
from jedi import cache
|
||||||
|
|||||||
Reference in New Issue
Block a user