unable to catch this exception

mk mrkafk at gmail.com
Tue Feb 2 12:20:34 CET 2010


Exception in thread Thread-9 (most likely raised during interpreter 
shutdown):
Traceback (most recent call last):
   File "/usr/local/lib/python2.6/threading.py", line 522, in 
__bootstrap_inner
   File "/var/www/html/cssh.py", line 875, in run
   File "/var/www/html/cssh.py", line 617, in ssh_connect
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 
'BadAuthenticationType'


This happens on interpreter shutdown, even though I do try to catch the 
AttributeError exception:

try:
     fake = paramiko.BadAuthenticationType
     try:
         self.conobj.connect(self.ip, username=self.username, 
key_filename=self.sshprivkey, port=self.port, timeout=opts.timeout)
         loginsuccess = True
     except paramiko.BadAuthenticationType, e: # this is line 617
         self.conerror = str(e)
     except paramiko.SSHException, e:
         self.conerror = str(e)
     except socket.timeout, e:
         self.conerror = str(e)
     except socket.error, e:
         self.conerror = str(e)
except AttributeError:
     # this happens on interpreter shutdown
     self.conerror = 'shutdown'


It's clear what happens: paramiko gets its attributes cleared or the 
module perhaps gets unloaded and as result "paramiko" label leads to 
None, which obviously has no attribute BadAuthenticationType.

However, even though this is surrounded by try .. except AttributeError 
block, it evidently isn't catch. How to catch that exception? Or at 
least preven displaying this message?

Regards,
mk




More information about the Python-list mailing list