RE: Context Manager getting str instead of AttributeError instance

2012-03-15 Thread Peter Otten
Prasad, Ramit wrote: >> Prasad, Ramit wrote: >> >> > 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 excepti

Re: Context Manager getting str instead of AttributeError instance

2012-03-15 Thread Ian Kelly
On Thu, Mar 15, 2012 at 2:25 PM, Prasad, Ramit wrote: >> > ... >> > (, "'A' object has no attribute 'x'", >> ) >> > AttributeError: 'A' object has no attribute 'x' >> > >> > As you can see, I am getting a string while you are not. >> >>Ian Kelly said: >> Looks like a version difference.  I don't h

RE: Context Manager getting str instead of AttributeError instance

2012-03-15 Thread Prasad, Ramit
> > ... > > (, "'A' object has no attribute 'x'", > ) > > AttributeError: 'A' object has no attribute 'x' > > > > As you can see, I am getting a string while you are not. > >Ian Kelly said: > Looks like a version difference. I don't have Python 2.6 handy to > test on, but I get a str in Python 2

Re: Context Manager getting str instead of AttributeError instance

2012-03-15 Thread Ian Kelly
On Thu, Mar 15, 2012 at 1:10 PM, Prasad, Ramit wrote: >> Prasad, Ramit wrote: >> >> > So I have a context manager used to catch errors >> > >> > def __exit__( self, exceptionClass, exception, tracebackObject ): >> >     if isinstance( exception, self.exceptionClasses ): >> >          #do something

RE: Context Manager getting str instead of AttributeError instance

2012-03-15 Thread Prasad, Ramit
> Prasad, Ramit wrote: > > > 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 insta

Re: Context Manager getting str instead of AttributeError instance

2012-03-15 Thread Peter Otten
Prasad, Ramit wrote: > 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 > A

Context Manager getting str instead of AttributeError instance

2012-03-15 Thread Prasad, Ramit
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