Skip to content

Commit

Permalink
issue #426: tighten up PushFileService types.
Browse files Browse the repository at this point in the history
Bytes/Unicode mixing caused a hang, so prevent bytes entirely.
  • Loading branch information
dw committed Jan 19, 2019
1 parent 8fa3c74 commit 04755c3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ansible_mitogen/planner.py
Expand Up @@ -172,7 +172,7 @@ def detect(self):
return module_common._is_binary(self._inv.module_source)

def get_push_files(self):
return [self._inv.module_path]
return [mitogen.core.to_text(self._inv.module_path)]

def get_kwargs(self, **kwargs):
return super(BinaryPlanner, self).get_kwargs(
Expand Down Expand Up @@ -285,7 +285,7 @@ def _get_interpreter(self):

def get_push_files(self):
return super(NewStylePlanner, self).get_push_files() + [
path
mitogen.core.to_text(path)
for fullname, path, is_pkg in self.get_module_map()['custom']
]

Expand Down
6 changes: 4 additions & 2 deletions ansible_mitogen/services.py
Expand Up @@ -492,14 +492,16 @@ def __init__(self, *args, **kwargs):

def _get_builtin_names(self, builtin_path, resolved):
return [
fullname
mitogen.core.to_text(fullname)
for fullname, path, is_pkg in resolved
if os.path.abspath(path).startswith(builtin_path)
]

def _get_custom_tups(self, builtin_path, resolved):
return [
(fullname, path, is_pkg)
(mitogen.core.to_text(fullname),
mitogen.core.to_text(path),
is_pkg)
for fullname, path, is_pkg in resolved
if not os.path.abspath(path).startswith(builtin_path)
]
Expand Down
3 changes: 2 additions & 1 deletion mitogen/service.py
Expand Up @@ -594,6 +594,7 @@ def __init__(self, **kwargs):
self._sent_by_stream = {}

def get(self, path):
assert isinstance(path, mitogen.core.UnicodeType)
self._lock.acquire()
try:
if path in self._cache:
Expand Down Expand Up @@ -670,7 +671,7 @@ def _store(self, path, data):
@expose(policy=AllowParents())
@no_reply()
@arg_spec({
'path': mitogen.core.FsPathTypes,
'path': mitogen.core.UnicodeType,
'data': mitogen.core.Blob,
'context': mitogen.core.Context,
})
Expand Down

0 comments on commit 04755c3

Please sign in to comment.