YCM client now sends utf-8 encoded JSON.
Previously, we'd just use json.dumps() to dump out JSON. By default, ensure_ascii is set to true and non-ASCII chars are encoded as \uXXXX. Problems seem to happen with other text in the data then not being utf8. I'm not sure why, still can't repro. This should go away now that we explicitly build a unicode string which we then encode as utf8. Hopefully fixes #821.
This commit is contained in:
parent
36436d03b6
commit
2f051ee9f1
@ -18,13 +18,13 @@
|
||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import vim
|
||||
import json
|
||||
import requests
|
||||
import urlparse
|
||||
from retries import retries
|
||||
from requests_futures.sessions import FuturesSession
|
||||
from ycm.unsafe_thread_pool_executor import UnsafeThreadPoolExecutor
|
||||
from ycm import vimsupport
|
||||
from ycm.utils import ToUtf8Json
|
||||
from ycm.server.responses import ServerError, UnknownExtraConf
|
||||
|
||||
_HEADERS = {'content-type': 'application/json'}
|
||||
@ -89,7 +89,7 @@ class BaseRequest( object ):
|
||||
def SendRequest( data, handler, method, timeout ):
|
||||
if method == 'POST':
|
||||
return BaseRequest.session.post( _BuildUri( handler ),
|
||||
data = json.dumps( data ),
|
||||
data = ToUtf8Json( data ),
|
||||
headers = _HEADERS,
|
||||
timeout = timeout )
|
||||
if method == 'GET':
|
||||
@ -101,7 +101,7 @@ class BaseRequest( object ):
|
||||
def DelayedSendRequest( data, handler, method ):
|
||||
if method == 'POST':
|
||||
return requests.post( _BuildUri( handler ),
|
||||
data = json.dumps( data ),
|
||||
data = ToUtf8Json( data ),
|
||||
headers = _HEADERS )
|
||||
if method == 'GET':
|
||||
return requests.get( _BuildUri( handler ),
|
||||
|
@ -24,6 +24,7 @@ import signal
|
||||
import functools
|
||||
import socket
|
||||
import stat
|
||||
import json
|
||||
from distutils.spawn import find_executable
|
||||
import subprocess
|
||||
|
||||
@ -47,6 +48,10 @@ def ToUtf8IfNeeded( value ):
|
||||
return str( value )
|
||||
|
||||
|
||||
def ToUtf8Json( data ):
|
||||
return ToUtf8IfNeeded( json.dumps( data, ensure_ascii = False ) )
|
||||
|
||||
|
||||
def PathToTempDir():
|
||||
tempdir = os.path.join( tempfile.gettempdir(), 'ycm_temp' )
|
||||
if not os.path.exists( tempdir ):
|
||||
|
Loading…
Reference in New Issue
Block a user