aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilippe Crama <pcfeb0009@gmx.com>2011-01-21 15:17:03 +0100
committerMiklos Vajna <vmiklos@frugalware.org>2011-01-21 15:17:03 +0100
commitf5035854dcaef6112ff71a111d071e93708bf082 (patch)
tree6625947d9c16c55b0b38c9b7d23f8be358e670b0
parenta86612f10adb66d97c8a725c7f689da1ad7c717b (diff)
Avoid debugging output charset problems crashing skyped.py
When using irssi in an LC_CTYPE=ISO-8859-1 terminal (thus /set charset iso-8859-1 for irssi, set charset iso-8859-1 for bitlbee and no recode_out_default_charset set for irssi) and skyped.py in a Windows console window (CP1252?), sending a message with a &eacute; (the character, not the HTML entity) crashes the server because in its debugging output it tries to print the UTF-8 equivalent intepreted as CP1252 code points. I do not think that the "if options.log: ..." code just below the patch needs the same treatment as the worst that can happen is that some messages in the log file will be garbled. Since I do not use/test that code path, I didn't touch it.
-rw-r--r--skype/skyped.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/skype/skyped.py b/skype/skyped.py
index bfb09d12..8f69e2ee 100644
--- a/skype/skyped.py
+++ b/skype/skyped.py
@@ -198,7 +198,17 @@ def dprint(msg):
now = strftime("%Y-%m-%d %H:%M:%S")
if options.debug:
- print now + ": " + msg
+ try:
+ print now + ": " + msg
+ except Exception, s:
+ try:
+ sanitized = msg.encode("ascii", "backslashreplace")
+ except Error, s:
+ try:
+ sanitized = "hex [" + msg.encode("hex") + "]"
+ except Error, s:
+ sanitized = "[unable to print debug message]"
+ print now + "~=" + sanitized
sys.stdout.flush()
if options.log:
sock = open(options.log, "a")