i think it is bad to rely on sys.stdout, some programs do not have it set (like a python module running in wsgi with apache2 server). it's safer to use:
return result.encode(sys.getfilesystemencoding() or "ascii", "replace")
i think it is bad to rely on sys.stdout, some programs do not have it set (like a python module running in wsgi with apache2 server). it's safer to use:
return result. encode( sys.getfilesyst emencoding( ) or "ascii", "replace")