1
0
forked from VimPlug/jedi

print_to_stderr can be replaced with a proper future import

This commit is contained in:
Dave Halter
2019-04-03 09:36:04 +02:00
parent c997d568f3
commit c0f5c5f24c
4 changed files with 8 additions and 14 deletions

View File

@@ -165,7 +165,6 @@ def find_module_pre_py3(string, path=None, full_name=None, is_global_search=True
loader = pkgutil.get_importer(item)
if loader:
loader = loader.find_module(string)
print_to_stderr('lalala')
return _from_loader(loader, string)
raise ImportError("No module named {}".format(string))
@@ -387,12 +386,6 @@ def no_unicode_pprint(dct):
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):
"""
``__repr__`` methods in Python 2 don't allow unicode objects to be

View File

@@ -1,12 +1,12 @@
from __future__ import print_function
import inspect
import types
import sys
from textwrap import dedent
import operator as op
from collections import namedtuple
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
@@ -134,13 +134,13 @@ def load_module(evaluator, dotted_name, sys_path):
__import__(dotted_name)
except ImportError:
# 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
except Exception:
# Since __import__ pretty much makes code execution possible, just
# catch any error here and print it.
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
finally:
sys.path = temp

View File

@@ -22,7 +22,7 @@ except ImportError:
from Queue import Queue, Empty # python 2.7
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.cache import memoize_method
from jedi.evaluate.compiled.subprocess import functions

View File

@@ -1,8 +1,9 @@
from __future__ import print_function
import sys
import os
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 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.
"""
if stderr is not None:
print_to_stderr(stderr)
print(stderr, file=sys.stderr)
sys.stderr.flush()
if stdout is not None:
print(stdout)