[Python-Dev] a quit that actually quits

Fredrik Lundh fredrik at pythonware.com
Wed Dec 28 11:51:51 CET 2005


Martin v. Löwis wrote:

> Introducing sys.commandline is fine; overriding sys.excepthook
> still worrisome.
>
> What's wrong with triggering this in some __repr__ implementation?

because simple introspection may exit your program.  unexpected
exits are a lot more annoying than unexpected non-exits.

> If an excepthook must be installed, why couldn't the previous
> excepthook be preserved, and called in case the exception is
> not what you are looking for?

this is done in site.py, before sitecustomize is loaded.  I'm not sure
how anyone else would be able to squeeze in an excepthook at this
point, even if they wanted...

> Of course, even if this excepthook behaves friendly, some other
> package might overwrite excepthook without preserving yours,
> in which case people would "sometimes" get a NameError when
> they try to exit.

sure, but people may sometimes get another result if they rebind
exit (e.g. from sys import *), plug in a broken displayhook, or other-
wise mess up their system.

as long the documentation mentions how this works, and urges
excepthook developers to be careful, I don't really see this as a
problem.

</F>





More information about the Python-Dev mailing list