Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64077
| Date | 2014-01-16 13:34 +0100 |
|---|---|
| From | Ernest Adrogué <nfdisco@gmail.com> |
| Subject | Unicode strings as arguments to exceptions |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5586.1389876759.18130.python-list@python.org> (permalink) |
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 call last):
File "<stdin>", line 1, in <module>
KeyError: u'\xe4'
On the other hand ValueError doesn't print anything.
>>> raise ValueError('a')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: a
>>> raise ValueError(u'ä')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError
I'm using Python 2.7.6 on a Unix machine.
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Unicode strings as arguments to exceptions Ernest Adrogué <nfdisco@gmail.com> - 2014-01-16 13:34 +0100
Re: Unicode strings as arguments to exceptions Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-16 14:16 +0000
Re: Unicode strings as arguments to exceptions Roy Smith <roy@panix.com> - 2014-01-16 09:32 -0500
Re: Unicode strings as arguments to exceptions Terry Reedy <tjreedy@udel.edu> - 2014-01-16 18:48 -0500
csiph-web