I use a Python script written in 2.7 (seafile-cli
, from Seafile, a file synchronization solution).
I know that unicode is problematic in Python 2 but the filenames with diacritic signs are thankfully handled correctly when starting the script:
$ # seaf-cli status
# Name Status Progress
photos downloading 0/0, 0.0KB/s
Ma bibliothèque downloading 566/1770, 1745.7KB/s
videos downloading 28/1203, 5088.0KB/s
dev-perso downloading 0/0, 0.0KB/s
dev-pro downloading 0/0, 0.0KB/s
To my surprise, when piping this output, the Python script crashes with UnicodeEncodeError
:
$ seaf-cli status | cat -
# Name Status Progress
photos downloading 0/0, 0.0KB/s
Traceback (most recent call last):
File "/usr/bin/seaf-cli", line 845, in <module>
main()
File "/usr/bin/seaf-cli", line 841, in main
args.func(args)
File "/usr/bin/seaf-cli", line 649, in seaf_status
tx_task.rate/1024.0)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in position 11: ordinal not in range(128)
While I understand that it might have had issues with Ma bibliothèque
in the first place (which it has not), why piping it triggers a Traceback?
Shouldn't that be the problem of the shell? - the output has "left" the script at that point.
EDIT: the answer is in another question. Marking as duplicate.