1
0
forked from VimPlug/jedi

source_to_unicode -> python_bytes_to_unicode.

This commit is contained in:
Dave Halter
2017-08-15 20:09:44 +02:00
parent f9e31dc941
commit fe9be9fe09
4 changed files with 10 additions and 10 deletions

View File

@@ -15,7 +15,7 @@ import sys
import parso
from parso.python import tree
from parso.utils import source_to_unicode, split_lines
from parso.utils import python_bytes_to_unicode, split_lines
from jedi.parser_utils import get_executable_nodes, get_statement_of_position
from jedi import debug
@@ -110,7 +110,7 @@ class Script(object):
source = f.read()
# TODO do we really want that?
self._source = source_to_unicode(source, encoding, errors='replace')
self._source = python_bytes_to_unicode(source, encoding, errors='replace')
self._code_lines = split_lines(self._source)
line = max(len(self._code_lines), 1) if line is None else line
if not (0 < line <= len(self._code_lines)):

View File

@@ -19,7 +19,7 @@ import sys
from parso.python import tree
from parso.tree import search_ancestor
from parso.cache import parser_cache
from parso.utils import source_to_unicode
from parso.utils import python_bytes_to_unicode
from jedi._compatibility import find_module, unicode, ImplicitNSInfo
from jedi import debug
@@ -510,7 +510,7 @@ def get_modules_containing_name(evaluator, modules, name):
def check_fs(path):
with open(path, 'rb') as f:
code = source_to_unicode(f.read(), errors='replace')
code = python_bytes_to_unicode(f.read(), errors='replace')
if name in code:
module_name = os.path.basename(path)[:-3] # Remove `.py`.
module = _load_module(evaluator, path, code)

View File

@@ -44,7 +44,7 @@ import re
from itertools import chain
from parso.python import tree
from parso.utils import source_to_unicode
from parso.utils import python_bytes_to_unicode
from jedi._compatibility import use_metaclass
from jedi import debug
@@ -548,7 +548,7 @@ class ModuleContext(use_metaclass(CachedMetaClass, context.TreeContext)):
init_path = self.py__file__()
if os.path.basename(init_path) == '__init__.py':
with open(init_path, 'rb') as f:
content = source_to_unicode(f.read(), errors='replace')
content = python_bytes_to_unicode(f.read(), errors='replace')
# these are strings that need to be used for namespace packages,
# the first one is ``pkgutil``, the second ``pkg_resources``.
options = ('declare_namespace(__name__)', 'extend_path(__path__')

View File

@@ -15,7 +15,7 @@ following functions (sometimes bug-prone):
import difflib
from jedi import common
from parso.utils import source_to_unicode, split_lines
from parso.utils import python_bytes_to_unicode, split_lines
from jedi.evaluate import helpers
@@ -83,7 +83,7 @@ def _rename(names, replace_str):
with open(current_path) as f:
source = f.read()
new_lines = split_lines(source_to_unicode(source))
new_lines = split_lines(python_bytes_to_unicode(source))
old_lines = new_lines[:]
nr, indent = name.line, name.column
@@ -101,7 +101,7 @@ def extract(script, new_name):
:type source: str
:return: list of changed lines/changed files
"""
new_lines = split_lines(source_to_unicode(script.source))
new_lines = split_lines(python_bytes_to_unicode(script.source))
old_lines = new_lines[:]
user_stmt = script._parser.user_stmt()
@@ -160,7 +160,7 @@ def inline(script):
"""
:type script: api.Script
"""
new_lines = split_lines(source_to_unicode(script.source))
new_lines = split_lines(python_bytes_to_unicode(script.source))
dct = {}