Unicode strings as arguments to exceptions

2014-01-16 Thread Ernest Adrogué
Hi, There seems to be some inconsistency in the way exceptions handle Unicode strings. For instance, KeyError seems to not have a problem with them raise KeyError('a') Traceback (most recent call last): File stdin, line 1, in module KeyError: 'a' raise KeyError(u'ä') Traceback (most recent

Re: Unicode strings as arguments to exceptions

2014-01-16 Thread Steven D'Aprano
On Thu, 16 Jan 2014 13:34:08 +0100, Ernest Adrogué wrote: Hi, There seems to be some inconsistency in the way exceptions handle Unicode strings. Yes. I believe the problem lies in the __str__ method. For example, KeyError manages to handle Unicode, although in an ugly way: py

Re: Unicode strings as arguments to exceptions

2014-01-16 Thread Roy Smith
In article 52d7e9a0$0$2$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Thu, 16 Jan 2014 13:34:08 +0100, Ernest Adrogué wrote: Hi, There seems to be some inconsistency in the way exceptions handle Unicode strings. Yes. I

Re: Unicode strings as arguments to exceptions

2014-01-16 Thread Terry Reedy
On 1/16/2014 7:34 AM, Ernest Adrogué wrote: Hi, There seems to be some inconsistency in the way exceptions handle Unicode strings. For instance, KeyError seems to not have a problem with them raise KeyError('a') Traceback (most recent call last): File stdin, line 1, in module KeyError:

Re: Unicode strings as arguments to exceptions

2014-01-16 Thread Terry Reedy
On 1/16/2014 9:16 AM, Steven D'Aprano wrote: On Thu, 16 Jan 2014 13:34:08 +0100, Ernest Adrogué wrote: Hi, There seems to be some inconsistency in the way exceptions handle Unicode strings. Yes. I believe the problem lies in the __str__ method. For example, KeyError manages to handle