mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-15 10:07:06 +08:00
Fixed issue with repr encoding (fixes davidhalter/jedi-vim#94)
This commit is contained in:
@@ -182,3 +182,8 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
# python 2.5
|
# python 2.5
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
|
|
||||||
|
try:
|
||||||
|
encoding = sys.stdout.encoding
|
||||||
|
except AttributeError:
|
||||||
|
encoding = 'ascii'
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ backtracking algorithm.
|
|||||||
|
|
||||||
.. todo:: nonlocal statement, needed or can be ignored? (py3k)
|
.. todo:: nonlocal statement, needed or can be ignored? (py3k)
|
||||||
"""
|
"""
|
||||||
from _compatibility import next, hasattr, is_py3k, unicode
|
from _compatibility import next, hasattr, is_py3k, unicode, utf8
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import itertools
|
import itertools
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import re
|
|||||||
import tokenize
|
import tokenize
|
||||||
|
|
||||||
from _compatibility import next, literal_eval, cleandoc, Python3Method, \
|
from _compatibility import next, literal_eval, cleandoc, Python3Method, \
|
||||||
property
|
property, encoding
|
||||||
import common
|
import common
|
||||||
import debug
|
import debug
|
||||||
|
|
||||||
@@ -92,9 +92,8 @@ class Simple(Base):
|
|||||||
self._end_pos = value
|
self._end_pos = value
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
code = self.get_code().replace('\n', ' ')
|
code = self.get_code().replace('\n', ' ').encode(encoding, 'replace')
|
||||||
return "<%s: %s@%s>" % \
|
return '<%s: %s@%s>' % (type(self).__name__, code, self.start_pos[0])
|
||||||
(type(self).__name__, code, self.start_pos[0])
|
|
||||||
|
|
||||||
|
|
||||||
class Scope(Simple):
|
class Scope(Simple):
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ class TestRegression(TestBase):
|
|||||||
completions1 = self.complete(s1)
|
completions1 = self.complete(s1)
|
||||||
assert 'strip' in [c.word for c in completions1]
|
assert 'strip' in [c.word for c in completions1]
|
||||||
s2 = utf8('#-*- coding: utf-8 -*-\nclass Person():\n name = "é"\n\nPerson().name.')
|
s2 = utf8('#-*- coding: utf-8 -*-\nclass Person():\n name = "é"\n\nPerson().name.')
|
||||||
completions = self.complete(s2)
|
completions2 = self.complete(s2)
|
||||||
assert 'strip' in [c.word for c in completions2]
|
assert 'strip' in [c.word for c in completions2]
|
||||||
|
|
||||||
def test_os_nowait(self):
|
def test_os_nowait(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user