--- __init__.py.orig Sat Apr 4 16:39:20 2009 +++ __init__.py Thu Apr 16 15:44:01 2009 @@ -764,11 +764,11 @@ stream.write(fs % msg) else: try: - if (isinstance(msg, unicode) or - getattr(stream, 'encoding', None) is None): - stream.write(fs % msg) - else: + if (isinstance(msg, unicode) and + getattr(stream, 'encoding')): stream.write(fs % msg.encode(stream.encoding)) + else: + stream.write(fs % msg) except UnicodeError: stream.write(fs % msg.encode("UTF-8")) self.flush()