At the moment you are encoding them using whatever Python's default
is. I think it would be both a bit clearer and a bit less likely to
cause confusing errors if you instead made it thing.encode('ascii',
'error') if they're really required to be always ascii safe.
At the moment you are encoding them using whatever Python's default 'ascii' ,
is. I think it would be both a bit clearer and a bit less likely to
cause confusing errors if you instead made it thing.encode(
'error') if they're really required to be always ascii safe.