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


Groups > comp.lang.python > #64077

Unicode strings as arguments to exceptions

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <nfdisco@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.024
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; "'a'": 0.09; 'strings.': 0.09; 'valueerror:': 0.09; 'python': 0.11; 'keyerror': 0.16; 'subject:Unicode': 0.16; 'valueerror': 0.16; 'seems': 0.21; '>>>': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'instance,': 0.24; 'unicode': 0.24; 'raise': 0.29; 'unix': 0.29; "doesn't": 0.30; "i'm": 0.30; '"",': 0.31; 'exceptions': 0.31; 'keyerror:': 0.31; 'file': 0.32; '(most': 0.33; 'problem': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'machine.': 0.36; 'hi,': 0.36; 'handle': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; '8bit%:6': 0.40; 'content-disposition:inline': 0.62; 'anything.': 0.68; 'hand': 0.80
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mime-version:content-type :content-disposition:content-transfer-encoding:user-agent; bh=y5MgImUZ1em1/w6mF+6ZBtgsE9dUBGGLMXNNljezGsU=; b=A4Md/amJFQJWhRSD1297XAbtEP2BqclcUinqtsfhVWN3C91SiZ4oVA2eEOhurS7Rhz oBqD6QZC5NzRG2DT/W7Mzl5qotuaGOJQz4zxFR8AbtbyB6kL2u3dM2FlCVLRI349M6PB iwf1SSMJ9nJvEulLniX4Wmk8F6aa5twyGPkttAAeQegWETfZkk+Lbq5Z3F6LbzLNYtEu 6RtvgaRdK9ikUTVlxERZZtb+1DFTHe0l3r6w9kbD786/AmlPLueC4GWiMBfbWlMVYJX0 XhZmj1w/X/stGTcOZdMGpsgPsmnPb+iriYZ8NaOmIogLnslUqyEGvQX7EaYnP0/Tapoa aLYg==
X-Received by 10.180.99.74 with SMTP id eo10mr7993778wib.12.1389875653046; Thu, 16 Jan 2014 04:34:13 -0800 (PST)
Date Thu, 16 Jan 2014 13:34:08 +0100
From Ernest Adrogué <nfdisco@gmail.com>
To python-list@python.org
Subject Unicode strings as arguments to exceptions
MIME-Version 1.0
Content-Type text/plain; charset=iso-8859-1
Content-Disposition inline
Content-Transfer-Encoding quoted-printable
X-Operating-System GNU/Linux (Debian jessie/sid)
User-Agent Mutt/1.5.21 (2010-09-15)
X-Mailman-Approved-At Thu, 16 Jan 2014 13:52:39 +0100
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5586.1389876759.18130.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1389876759 news.xs4all.nl 2976 [2001:888:2000:d::a6]:46940
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:64077

Show key headers only | View raw


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 | NextNext in thread | Find similar | Unroll thread


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