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)
# Subclass setuptools Extension to add a parameter specifying where the shared
# library should be placed after being compiled
评论列表
文章目录