fpgainfo: wrap stdout with codec StreamWriter
This change replaces `sys.stdout` with a StreamWriter object that uses
`UTF-8` encoding. This will allow fpgainfo to print unicode (non-ascii).
Without this, an exception will be raised when printing unicode
characters and redirecting the output stream.
Conflicts:
tools/fpgainfo/fpgainfo
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
import argparse
+import codecs
import fpga_common
import fpgaerr
import fpgapwr
@@ -65,4 +66,6 @@ if __name__ == "__main__":
logging.warning("Could not open log file: {}."
"Logging to stderr".format(logfile))
+ # wrap stdout with the StreamWriter that does unicode
+ sys.stdout = codecs.getwriter('UTF-8')(sys.stdout)
args.func(args)
