Commit 49a36f3c authored by nimrod's avatar nimrod
Browse files

Use subprocess32 only on Python2.7.

Since Python3.4 is EOL and Python3.5 has `run` in the `subprocess`
module, there's no need for it outside of Python2.7.
parent e463ab1d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ setup(
        "PyYAML",
        "jmespath",
        "toml",
        "subprocess32>=3.5.0",
        "subprocess32>=3.5.0;python_version<'3.5'",
    ],
    extras_require={"dev": ["pipenv"]},
    entry_points={"console_scripts": ["template=template:main"]},
+8 −3
Original line number Diff line number Diff line
@@ -157,11 +157,16 @@ def run(*argv, **kwargs):
    >>> run(['ls', 'foo'])['returncode'] > 0
    True
    """
    import subprocess32  # nosec
    import sys

    defaults = {"stdout": subprocess32.PIPE, "stderr": subprocess32.PIPE}
    if sys.version_info[0] < 3:  # nosec
        import subprocess32 as subprocess
    else:
        import subprocess

    defaults = {"stdout": subprocess.PIPE, "stderr": subprocess.PIPE}
    defaults.update(kwargs)
    proc = subprocess32.run(*argv, **defaults).__dict__
    proc = subprocess.run(*argv, **defaults).__dict__  # nosec
    if "text" not in kwargs or kwargs["text"]:
        proc["stdout"] = proc["stdout"].decode()
        proc["stderr"] = proc["stderr"].decode()