encoding = encoding or getattr(file, 'encoding', None)
Python: How to force a "print" to use __unicode__ instead of __str__, or otherwise naturally "print" the message without explicitly calling unicode()