On 19 May 2014 23:25, Emilio J. RodrÃguez-Posada <[email protected]> wrote:
> When I test my Python script in tools-dev, prints are OK. But when I > launch the script with jsub, I receive errors of Unicode: > > UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in > position 6: ordinal not in range(128) > > Why does it change among boxes? > > There are several reasons for this, but the most important one is output redirection. When writing to a terminal, Python will encode your unicode string with the current terminal encoding, but for a file, Python needs to know which encoding to use. See https://bugzilla.wikimedia.org/show_bug.cgi?id=58784 for some suggestions. The easiest option is making sure you write bytes to your output (i.e. explicitly .encode('utf-8') the unicode object). An easy way to test is running python scriptname.py | tee which should give you the same result as jsub -- apart from environment options.
_______________________________________________ Labs-l mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/labs-l
