]> git.ipfire.org Git - thirdparty/patchwork.git/commit
pwclient: Fix silent crash on python 2
authorRobin Jarry <robin.jarry@6wind.com>
Tue, 2 May 2017 14:51:51 +0000 (16:51 +0200)
committerStephen Finucane <stephen@that.guru>
Tue, 2 May 2017 20:48:01 +0000 (21:48 +0100)
commita3911c5b7ec0bef056f90bf3bab90712dcff91dc
treeea43f90ce342f6328b855ce2ebba9d7e985772f3
parent97b6a857181ac776011e704d9c81b1d4a27f2573
pwclient: Fix silent crash on python 2

Replacing sys.stdout and sys.stderr can cause obscure crashes when
trying to write non unicode data. The interpreter is terminated with
SIGINT without any specific error writen on the console.

  rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7f964820e8d0},
  {0x559f50, [], SA_RESTORER, 0x7f964820e8d0}, 8) = 0

This happens easily when there is an untrapped exception which should
lead to printing a traceback on stderr.

The only way to prevent UnicodeEncodeErrors is to make sure that one of
the locale-related environment variables (LC_ALL, LANG, LANGUAGE, etc.)
is set. Python will use the correct encoding accordingly.

Add a note about this on `pwclient --help`. Also, display a help message
when an encoding error occurs.

Fixes: 046419a3bf8f ("pwclient: Fix encoding problems")
Signed-off-by: Robin Jarry <robin.jarry@6wind.com>
Signed-off-by: Stephen Finucane <stephen@that.guru>
patchwork/bin/pwclient