def run(*argv, **kwargs):
    """
    Runs a command and returns the stdout, stderr and returncode
    using `run
    <https://docs.python.org/3.5/library/subprocess.html?highlight=popen#subprocess.run>`_.
    >>> run('ls')["returncode"] == 0
    True
    >>> 'SHELL' not in run('echo $SHELL', shell=True)['stdout']
    True
    >>> run(['ls', 'foo'])['returncode'] > 0
    True
    """
    import sys
    if sys.version_info[0] < 3:
        import subprocess32 as subprocess
    else:
        import subprocess
    defaults = {'stdout': subprocess.PIPE, 'stderr': subprocess.PIPE}
    defaults.update(kwargs)
    proc = subprocess.run(*argv, **defaults).__dict__
    if 'text' not in kwargs or kwargs['text']:
        proc['stdout'] = proc['stdout'].decode()
        proc['stderr'] = proc['stderr'].decode()
    return proc
