[Python-Dev] Deprecate sys.exitfunc? (original) (raw)

Guido van Rossum guido at python.org
Tue Aug 17 03:08:56 CEST 2004


The documentation for the atexit module (introduced in Py2.0) states:

"""Note: This module is unlikely to work correctly when used with other code that sets sys.exitfunc. In particular, other core Python modules are free to use atexit without the programmer's knowledge. Authors who use sys.exitfunc should convert their code to use atexit instead. The simplest way to convert code that sets sys.exitfunc is to import atexit and register the function that had been bound to sys.exitfunc.""" Can we strengthen this by deprecating sys.exitfunc? The atexit module does attempt to co-exist by introducing code to register a function in sys.exitfunc if it were defined before "import atexit" was called. However, this is unreliable because it depends on import order and the library is free to introduce an earlier "import atexit" which would break code relying on the co-existance mechanism.

+1

(I think the quoted words were written before we had introduced a formal concept of deprecation -- atexit is quite old. :-)

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-Dev mailing list