Fix UnicodeError when writing to sys.stdout
Due to a bug the was fixed in Python-2.7, in Python-2.6 unicode strings that are written to sys.stdout (using sys.stdout.write) are not converted to bytestrings using the file.encoding. Instead sys.stdout.encoding is set to None, and the default encoding is used. We solve this by creating a wrapper to stdout, and encoding everything either with the file encoding, or with the `locale` prefered encoding.
Showing with 12 additions and 0 deletions