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


Groups > comp.lang.python > #21697

Context Manager getting str instead of AttributeError instance

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ramit.prasad@jpmorgan.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'context': 0.04; 'completeness': 0.05; 'instance,': 0.05; 'exception,': 0.07; 'subclasses': 0.09; 'exception': 0.12; 'def': 0.13; 'to:name :python-list@python.org': 0.15; '712': 0.16; 'currencies': 0.16; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'from:addr:jpmorgan.com': 0.16; 'received:155.180': 0.16; 'received:155.180.234': 0.16; 'received:155.180.234.122': 0.16; 'received:159.53': 0.16; 'received:bankone.net': 0.16; 'received:exchad.jpmchase.net': 0.16; 'received:jpmchase.com': 0.16; 'received:jpmchase.net': 0.16; 'received:se3.svr.bankone.net': 0.16; 'received:svr.bankone.net': 0.16; 'securities,': 0.16; 'self,': 0.16; 'subject:instance': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'seems': 0.20; 'string': 0.24; 'classes': 0.26; 'received:169': 0.28; 'received:169.254': 0.28; 'received:155': 0.30; 'received:159': 0.30; 'use?': 0.30; 'accuracy': 0.32; 'instead.': 0.32; 'there': 0.33; 'normally': 0.34; 'header:Received:8': 0.34; 'subject:getting': 0.34; 'to:addr:python-list': 0.35; 'phone:': 0.35; 'something': 0.35; 'but': 0.37; 'charset:us-ascii': 0.37; 'listed': 0.38; 'to:addr:python.org': 0.40; 'subject': 0.61; 'offers': 0.62; 'here': 0.64; 'account': 0.66; 'taking': 0.66; 'information,': 0.69; 'legal': 0.72; 'url:email': 0.72; 'bank': 0.75; 'sale': 0.75; 'investment': 0.77; 'purchase': 0.78; 'received:169.254.8': 0.84
X-DKIM OpenDKIM Filter v2.1.3 sf1.jpmchase.com q2FHZ4v7013956
DKIM-Signature v=1; a=rsa-sha256; c=simple/simple; d=jpmorgan.com; s=smtpout; t=1331832904; bh=9UK6O3vsb+Qcm5sp4Yk/9h+zz7hKzBNH8+GG0ADBLr4=; h=From:To:Subject:Date:Message-ID:Content-Transfer-Encoding: MIME-Version:Content-Type; b=klATm6ti7hWPfMZesx4RenJY14yyWD6giiyQWGCSpBTof7S/lwfY0fNlM8B55N0nt 9jKwpMmHW9bPQENtQz2eXChYfbppw5W5MVBeUUlYqXXAlOlf+8399KYNwJ6dTY253e b/wUoO3O1Hx1E53BrrA1jQ4x92KC9d5uFMXPuJnI=
From "Prasad, Ramit" <ramit.prasad@jpmorgan.com>
To "python-list@python.org" <python-list@python.org>
Subject Context Manager getting str instead of AttributeError instance
Thread-Topic Context Manager getting str instead of AttributeError instance
Thread-Index Ac0C0ee2HWpMrUyoSZqdW3mY/u0Aug==
Date Thu, 15 Mar 2012 17:34:44 +0000
Accept-Language en-US
Content-Language en-US
X-MS-Has-Attach
X-MS-TNEF-Correlator
x-originating-ip [10.67.79.38]
Content-Transfer-Encoding quoted-printable
MIME-Version 1.0
X-DLP-FWD Yes
Content-Type text/plain; charset="us-ascii"
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.690.1331832913.3037.python-list@python.org> (permalink)
Lines 17
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1331832913 news.xs4all.nl 6959 [2001:888:2000:d::a6]:34187
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:21697

Show key headers only | View raw


So I have a context manager used to catch errors

def __exit__( self, exceptionClass, exception, tracebackObject ):
    if isinstance( exception, self.exceptionClasses ):
         #do something here

Normally exception would be the exception instance, but for 
AttributeError it seems to be a string instead. 

1) Why is AttributeError different than the other built-ins
in this respect?
2) Are there other standard errors like this (I know
that SystemExit is different as well)?
3) Taking into account that I want to include subclasses of 
classes listed in self.exceptionClasses, Is there a better check I can use?

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Context Manager getting str instead of AttributeError instance "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-03-15 17:34 +0000

csiph-web