Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #64114 > unrolled thread

Re: Unicode strings as arguments to exceptions

Started byTerry Reedy <tjreedy@udel.edu>
First post2014-01-16 18:09 -0500
Last post2014-01-16 18:09 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Unicode strings as arguments to exceptions Terry Reedy <tjreedy@udel.edu> - 2014-01-16 18:09 -0500

#64114 — Re: Unicode strings as arguments to exceptions

FromTerry Reedy <tjreedy@udel.edu>
Date2014-01-16 18:09 -0500
SubjectRe: Unicode strings as arguments to exceptions
Message-ID<mailman.5610.1389913787.18130.python-list@python.org>
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: '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.

Fixed at some point in 3.x. In 3.4b2:
 >>> ValueError(b'a')
ValueError(b'a',)
 >>> ValueError('a')
ValueError('a',)



-- 
Terry Jan Reedy

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web