def write(self, s):
# Ensure we always write bytes. This means that wrapped code calling
# print(<a string object>) in Python 3 will still work. Sigh.
if isinstance(s, six.text_type):
s = s.encode('utf-8')
# Write out to our capturing object & any CC's
IO.write(self, s)
for writer in self.cc:
writer.write(s)
# Dumb hack to deal with py3 expectations; real sys.std(out|err) in Py3
# requires writing to a buffer attribute obj in some situations.
评论列表
文章目录