'Run \'script\' lines with pdb and the pdb \'commands\'.'

def run_pdb(self, script, commands):

    filename = 'main.py'
    with open(filename, 'w') as f:
        f.write(textwrap.dedent(script))
    self.addCleanup(support.unlink, filename)
    self.addCleanup(support.rmtree, '__pycache__')
    cmd = [sys.executable, '-m', 'pdb', filename]
    stdout = stderr = None
    with subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT) as proc:
        (stdout, stderr) = proc.communicate(str.encode(commands))
    stdout = (stdout and bytes.decode(stdout))
    stderr = (stderr and bytes.decode(stderr))
    return (stdout, stderr)
