From 4636e244ea99eff81248afb36aa5c39ea58bfcb3 Mon Sep 17 00:00:00 2001 From: Gerko de Roo Date: Sun, 31 Jan 2010 17:58:48 +0100 Subject: [PATCH] Codec errors seem to lock up HUD with windows. I've made a trap for each error that I observed. don't want to halt the program so I return the original string. The de/recoding is not needed for >95% of the playernames anyway. --- pyfpdb/Charset.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/pyfpdb/Charset.py b/pyfpdb/Charset.py index 6b5e6b7c..02b5c098 100644 --- a/pyfpdb/Charset.py +++ b/pyfpdb/Charset.py @@ -41,7 +41,13 @@ def to_utf8(s): return _out except UnicodeDecodeError: sys.stderr.write('Could not convert: "%s"\n' % s) - raise + return s + except UnicodeEncodeError: + sys.stderr.write('Could not convert: "%s"\n' % s) + return s + except TypeError: + sys.stderr.write('Could not convert: "%s"\n' % s) + return s def to_db_utf8(s): if not_needed2: return s @@ -51,7 +57,13 @@ def to_db_utf8(s): return _out except UnicodeDecodeError: sys.stderr.write('Could not convert: "%s"\n' % s) - raise + return s + except UnicodeEncodeError: + sys.stderr.write('Could not convert: "%s"\n' % s) + return s + except TypeError: + sys.stderr.write('Could not convert: "%s"\n' % s) + return s def to_gui(s): if not_needed3: return s @@ -61,5 +73,11 @@ def to_gui(s): return _out except UnicodeDecodeError: sys.stderr.write('Could not convert: "%s"\n' % s) - raise + return s + except UnicodeEncodeError: + sys.stderr.write('Could not convert: "%s"\n' % s) + return s + except TypeError: + sys.stderr.write('Could not convert: "%s"\n' % s) + return s