diff options
-rw-r--r-- | cloudinit/distros/__init__.py | 8 | ||||
-rw-r--r-- | cloudinit/util.py | 9 |
2 files changed, 6 insertions, 11 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index 6b96d58c..00fb95fb 100644 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -36,14 +36,6 @@ from cloudinit import util from cloudinit.distros.parsers import hosts -try: - # Python 3 - from six import filter -except ImportError: - # Python 2 - from itertools import ifilter as filter - - OSFAMILIES = { 'debian': ['debian', 'ubuntu'], diff --git a/cloudinit/util.py b/cloudinit/util.py index 94fd5c70..25c104c7 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -1589,9 +1589,12 @@ def subp(args, data=None, rcs=None, env=None, capture=True, shell=False, stdout = subprocess.PIPE stderr = subprocess.PIPE stdin = subprocess.PIPE - sp = subprocess.Popen(args, stdout=stdout, - stderr=stderr, stdin=stdin, - env=env, shell=shell) + kws = dict(stdout=stdout, stderr=stderr, stdin=stdin, + env=env, shell=shell) + if six.PY3: + # Use this so subprocess output will be (Python 3) str, not bytes. + kws['universal_newlines'] = True + sp = subprocess.Popen(args, **kws) (out, err) = sp.communicate(data) except OSError as e: raise ProcessExecutionError(cmd=args, reason=e) |