Some more small improvements for Python 2

This commit is contained in:
Dave Halter
2017-12-28 23:58:19 +01:00
parent 4b72a89379
commit 05b2906dcc
2 changed files with 5 additions and 4 deletions

View File

@@ -344,7 +344,7 @@ class CompiledObjectFilter(AbstractFilter):
# ``dir`` doesn't include the type names.
if not self._is_instance and needs_type_completions:
for filter in builtin_from_name(self._evaluator, 'type').get_filters():
for filter in builtin_from_name(self._evaluator, u'type').get_filters():
names += filter.values()
return names

View File

@@ -142,6 +142,10 @@ class _Subprocess(object):
)
def _send(self, evaluator_id, function, args=(), kwargs={}):
if not is_py3:
# Python 2 compatibility
kwargs = {force_unicode(key): value for key, value in kwargs.items()}
data = evaluator_id, function, args, kwargs
pickle.dump(data, self._process.stdin, protocol=_PICKLE_PROTOCOL)
self._process.stdin.flush()
@@ -294,9 +298,6 @@ class AccessHandle(object):
happen. They are also the only unhashable objects that we're passing
around.
"""
# Python 2 compatibility
kwargs = {force_unicode(key): value for key, value in kwargs.items()}
if args and isinstance(args[0], slice):
return self._subprocess.get_compiled_method_return(self.id, name, *args, **kwargs)
return self._cached_results(name, *args, **kwargs)