<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def stdchannel_redirected(stdchannel):
 """ Redirects stdout or stderr to a StringIO object. As of python 3.4, there is a standard library contextmanager for this, but backwards compatibility! """

    try:
        s = io.StringIO()
        old = getattr(sys, stdchannel)
        setattr(sys, stdchannel, s)
        yield s
    finally:
        setattr(sys, stdchannel, old)