> > try: > > self.close() > > except: > > try: > > if not sys.exiting(): raise > > except: > > pass > > > > > > Or better yet, do as we have done often here, just catch the particular > > problem that occurs during shutdown, most often name error: > > > > try: > > self.close() > > except (AttributeError, NameError): > > pass > > From: Amaury Forgeot d'Arc [mailto:amaur...@gmail.com] > I suggest "except Exception": SystemExit and KeyboardInterrupt inherit > from BaseException, not from Exceptions > And close() is likely to raise IOErrors.
Ah, but that is not what the intent is to guard agains, according the comments. During exit, modules have been deleted and all sorts of things have gone away. It is therefore likely that code that executes during exit will encounter NameErrors (when a module is being cleaned up and its globals removed) And AttributeErrors. ImportErrors too, in fact. It would be good to see the actual repro case that caused this to be added in the first place, so that we could selectively catch those errors. Kristján _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com