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


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

Context Manager getting str instead of AttributeError instance

Started by"Prasad, Ramit" <ramit.prasad@jpmorgan.com>
First post2012-03-15 17:34 +0000
Last post2012-03-15 17:34 +0000
Articles 1 — 1 participant

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


Contents

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

#21697 — Context Manager getting str instead of AttributeError instance

From"Prasad, Ramit" <ramit.prasad@jpmorgan.com>
Date2012-03-15 17:34 +0000
SubjectContext Manager getting str instead of AttributeError instance
Message-ID<mailman.690.1331832913.3037.python-list@python.org>
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.  

[toc] | [standalone]


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


csiph-web