mirror of
https://github.com/davidhalter/jedi.git
synced 2026-02-16 07:12:00 +08:00
Don't cast bytes to strings when unpickling
This commit is contained in:
@@ -14,7 +14,7 @@ import weakref
|
|||||||
import pickle
|
import pickle
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from jedi._compatibility import queue
|
from jedi._compatibility import queue, is_py3
|
||||||
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
|
||||||
from jedi.evaluate.compiled.access import DirectObjectAccess, AccessPath, \
|
from jedi.evaluate.compiled.access import DirectObjectAccess, AccessPath, \
|
||||||
@@ -35,6 +35,13 @@ def get_subprocess(executable):
|
|||||||
return sub
|
return sub
|
||||||
|
|
||||||
|
|
||||||
|
def _pickle_load(file):
|
||||||
|
if is_py3:
|
||||||
|
return pickle.load(file, encoding='bytes')
|
||||||
|
else:
|
||||||
|
return pickle.load(file)
|
||||||
|
|
||||||
|
|
||||||
def _get_function(name):
|
def _get_function(name):
|
||||||
return getattr(functions, name)
|
return getattr(functions, name)
|
||||||
|
|
||||||
@@ -138,7 +145,7 @@ class _Subprocess(object):
|
|||||||
data = evaluator_id, function, args, kwargs
|
data = evaluator_id, function, args, kwargs
|
||||||
pickle.dump(data, self._process.stdin, protocol=_PICKLE_PROTOCOL)
|
pickle.dump(data, self._process.stdin, protocol=_PICKLE_PROTOCOL)
|
||||||
self._process.stdin.flush()
|
self._process.stdin.flush()
|
||||||
is_exception, result = pickle.load(self._process.stdout)
|
is_exception, result = _pickle_load(self._process.stdout)
|
||||||
if is_exception:
|
if is_exception:
|
||||||
raise result
|
raise result
|
||||||
return result
|
return result
|
||||||
@@ -237,7 +244,7 @@ class Listener(object):
|
|||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
payload = pickle.load(stdin)
|
payload = _pickle_load(stdin)
|
||||||
except EOFError:
|
except EOFError:
|
||||||
# It looks like the parent process closed. Don't make a big fuss
|
# It looks like the parent process closed. Don't make a big fuss
|
||||||
# here and just exit.
|
# here and just exit.
|
||||||
|
|||||||
Reference in New Issue
Block a user