<commit_before>import collections
import subprocess

try:
    from subprocess import run as subprocess_run
except ImportError:
    _CompletedProcess = collections.namedtuple('_CompletedProcess', ['args', 'retcode', 'stdout', 'stderr'])


    def subprocess_run(command, stdin=None, input=None, check=False, stdout=None, stderr=None):
        if input is not None:
            if stdin is not None:
                raise ValueError('stdin and input arguments can not be used at the same time.')
            stdin = subprocess.PIPE

        with subprocess.Popen(command, stdin=stdin,
                              stdout=stdout, stderr=stderr) as process:
            try:
                stdout, stderr = process.communicate(input=input)
            except:
                process.kill()
                process.wait()
                raise
            retcode = process.poll()
            if check and retcode:
                raise subprocess.CalledProcessError(retcode, process.args,
                                                    output=stdout, stderr=stderr)
        return _CompletedProcess(args=process.args, retcode=retcode,
                                 stdout=stdout, stderr=stderr)<commit_msg>Added backported CalledProcessError implementation for Python < 3.5 to future module.<commit_after>import collections
import subprocess

try:
    from subprocess import run as subprocess_run
    from subprocess import CalledProcessError
except ImportError:
    _CompletedProcess = collections.namedtuple('_CompletedProcess', ['args', 'retcode', 'stdout', 'stderr'])

    class CalledProcessError(subprocess.CalledProcessError):
        def __init__(self, returncode, cmd, output=None, stderr=None):
            super().__init__(returncode, cmd, output)
            self.stderr = stderr

        @property
        def stdout(self):
            return self.output

        @stdout.setter
        def stdout(self, value):
            self.output = value

    def subprocess_run(command, stdin=None, input=None, check=False, stdout=None, stderr=None):
        if input is not None:
            if stdin is not None:
                raise ValueError('stdin and input arguments can not be used at the same time.')
            stdin = subprocess.PIPE

        with subprocess.Popen(command, stdin=stdin,
                              stdout=stdout, stderr=stderr) as process:
            try:
                stdout, stderr = process.communicate(input=input)
            except:
                process.kill()
                process.wait()
                raise
            retcode = process.poll()
            if check and retcode:
                raise CalledProcessError(returncode=retcode, cmd=process.args,
                                                    output=stdout, stderr=stderr)
        return _CompletedProcess(args=process.args, retcode=retcode,
                                 stdout=stdout, stderr=stderr)
{'fraction_non_alphanumeric': 0.07810368349249659, 'fraction_numerical': 0.0006821282401091405, 'mean_word_length': 1.9806910569105691, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2589753', 'n_tokens_mistral': 737, 'n_tokens_neox': 707, 'n_words': 200}