Message 176512 - Python tracker (original) (raw)
Keep in mind that it's pretty easy to roll your own CM wrapper:
@contextlib.contextmanager def closes(file): yield file file.close()
Then you can do this:
with closes(StringIO()) as test: test.write("hi!") return test.getvalue()
This works for 2.5 and up.