human
Complete this python program:
def MonkeyPatchPdb(pdb):
assistant
#Here is the Python code you requested.

    """Given a reference to the pdb module, fix its set_trace function.
    This will allow the standard trick of setting a breakpoint in your
    code by inserting a call to pdb.set_trace() to work properly, as
    long as the original stdin and stdout of dev_appserver.py are
    connected to a console or shell window.
    """
    def NewSetTrace():
        'Replacement    for    set_trace()    that    uses    the    original    i/o    streams.\n\n                This    is    necessary    because    by    the    time    the    user    code    that    might\n                invoke    pdb.set_trace()    runs,    the    default    sys.stdin    and    sys.stdout\n                are    redirected    to    the    HTTP    request    and    response    streams    instead,\n                so    that    pdb    will    encounter    garbage    (or    EOF)    in    its    input,    and    its\n                output    will    garble    the    HTTP    response.        Fortunately,    sys.__stdin__\n                and    sys.__stderr__    retain    references    to    the    original    streams    --\n                this    is    a    standard    Python    feature.        Also,    fortunately,    as    of\n                Python    2.5,    the    Pdb    class    lets    you    easily    override    stdin    and\n                stdout.        The    original    set_trace()    function    does    essentially    the\n                same    thing    as    the    code    here    except    it    instantiates    Pdb()    without\n                arguments.\n                '
        p = pdb.Pdb(stdin=sys.__stdin__, stdout=sys.__stdout__)
        p.set_trace(sys._getframe().f_back)
    pdb.set_trace = NewSetTrace