forked from VimPlug/jedi
print_to_stderr can be replaced with a proper future import
This commit is contained in:
@@ -165,7 +165,6 @@ def find_module_pre_py3(string, path=None, full_name=None, is_global_search=True
|
|||||||
loader = pkgutil.get_importer(item)
|
loader = pkgutil.get_importer(item)
|
||||||
if loader:
|
if loader:
|
||||||
loader = loader.find_module(string)
|
loader = loader.find_module(string)
|
||||||
print_to_stderr('lalala')
|
|
||||||
return _from_loader(loader, string)
|
return _from_loader(loader, string)
|
||||||
raise ImportError("No module named {}".format(string))
|
raise ImportError("No module named {}".format(string))
|
||||||
|
|
||||||
@@ -387,12 +386,6 @@ def no_unicode_pprint(dct):
|
|||||||
print(re.sub("u'", "'", s))
|
print(re.sub("u'", "'", s))
|
||||||
|
|
||||||
|
|
||||||
def print_to_stderr(*args):
|
|
||||||
if is_py3:
|
|
||||||
print(*args, file=sys.stderr)
|
|
||||||
sys.stderr.flush()
|
|
||||||
|
|
||||||
|
|
||||||
def utf8_repr(func):
|
def utf8_repr(func):
|
||||||
"""
|
"""
|
||||||
``__repr__`` methods in Python 2 don't allow unicode objects to be
|
``__repr__`` methods in Python 2 don't allow unicode objects to be
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
|
from __future__ import print_function
|
||||||
import inspect
|
import inspect
|
||||||
import types
|
import types
|
||||||
import sys
|
import sys
|
||||||
from textwrap import dedent
|
|
||||||
import operator as op
|
import operator as op
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
from jedi._compatibility import unicode, is_py3, builtins, \
|
from jedi._compatibility import unicode, is_py3, builtins, \
|
||||||
py_version, force_unicode, print_to_stderr
|
py_version, force_unicode
|
||||||
from jedi.evaluate.compiled.getattr_static import getattr_static
|
from jedi.evaluate.compiled.getattr_static import getattr_static
|
||||||
|
|
||||||
|
|
||||||
@@ -134,13 +134,13 @@ def load_module(evaluator, dotted_name, sys_path):
|
|||||||
__import__(dotted_name)
|
__import__(dotted_name)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# If a module is "corrupt" or not really a Python module or whatever.
|
# If a module is "corrupt" or not really a Python module or whatever.
|
||||||
print_to_stderr('Module %s not importable in path %s.' % (dotted_name, sys_path))
|
print('Module %s not importable in path %s.' % (dotted_name, sys_path), file=sys.stderr)
|
||||||
return None
|
return None
|
||||||
except Exception:
|
except Exception:
|
||||||
# Since __import__ pretty much makes code execution possible, just
|
# Since __import__ pretty much makes code execution possible, just
|
||||||
# catch any error here and print it.
|
# catch any error here and print it.
|
||||||
import traceback
|
import traceback
|
||||||
print_to_stderr("Cannot import:\n%s" % traceback.format_exc())
|
print("Cannot import:\n%s" % traceback.format_exc(), file=sys.stderr)
|
||||||
return None
|
return None
|
||||||
finally:
|
finally:
|
||||||
sys.path = temp
|
sys.path = temp
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ except ImportError:
|
|||||||
from Queue import Queue, Empty # python 2.7
|
from Queue import Queue, Empty # python 2.7
|
||||||
|
|
||||||
from jedi._compatibility import queue, is_py3, force_unicode, \
|
from jedi._compatibility import queue, is_py3, force_unicode, \
|
||||||
pickle_dump, pickle_load, GeneralizedPopen, print_to_stderr
|
pickle_dump, pickle_load, GeneralizedPopen
|
||||||
from jedi import debug
|
from jedi import debug
|
||||||
from jedi.cache import memoize_method
|
from jedi.cache import memoize_method
|
||||||
from jedi.evaluate.compiled.subprocess import functions
|
from jedi.evaluate.compiled.subprocess import functions
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from jedi._compatibility import find_module, cast_path, force_unicode, \
|
from jedi._compatibility import find_module, cast_path, force_unicode, \
|
||||||
iter_modules, all_suffixes, print_to_stderr
|
iter_modules, all_suffixes
|
||||||
from jedi.evaluate.compiled import access
|
from jedi.evaluate.compiled import access
|
||||||
from jedi import parser_utils
|
from jedi import parser_utils
|
||||||
|
|
||||||
@@ -66,7 +67,7 @@ def _test_print(evaluator, stderr=None, stdout=None):
|
|||||||
Force some prints in the subprocesses. This exists for unit tests.
|
Force some prints in the subprocesses. This exists for unit tests.
|
||||||
"""
|
"""
|
||||||
if stderr is not None:
|
if stderr is not None:
|
||||||
print_to_stderr(stderr)
|
print(stderr, file=sys.stderr)
|
||||||
sys.stderr.flush()
|
sys.stderr.flush()
|
||||||
if stdout is not None:
|
if stdout is not None:
|
||||||
print(stdout)
|
print(stdout)
|
||||||
|
|||||||
Reference in New Issue
Block a user