Redirect output of bpy.ops.render.render() to variable I thought that the following code (which I found here) would save all the terminal output from the function bpy.ops.render.render() into the variable output:

import bpy, sys, io

old_stdout = sys.stdout
render_output = io.StringIO()
sys.stdout = render_output
bpy.ops.render.render( write_still=True )
sys.stdout = old_stdout


But I still get output to the terminal (Saved: /tmp/a.png Time: 00:00.99 (Saving: 00:00.01)) and render_output.getvalue() returns an empty string.  Why is that?

I also tested this method with bpy.ops.mesh.remove_doubles() and it successfully redirects the output.
It might have worked, if the bpy.ops.render.render() operator was outputting that information through Python. However, since that code is written in C (blender\source\blender\editors\render\render_internal.c), it doesn't care that you've reassigned sys.out in Python.