[Python-Dev] Is this a bug?
Georg Brandl
g.brandl at gmx.net
Fri Aug 11 10:28:09 CEST 2006
Georg Brandl wrote:
> Is this considered a bug? Sure, deleting modules from sys.modules
> isn't quite common, but it happened to me on one occasion.
>
> Python 2.4.3 (#1, Jul 29 2006, 10:52:20)
> >>> import logging
> >>> import sys
> >>> del logging
> >>> del sys.modules['logging']
> >>> ^D
> Error in atexit._run_exitfuncs:
> Traceback (most recent call last):
> File "/usr/lib/python2.4/atexit.py", line 24, in _run_exitfuncs
> func(*targs, **kargs)
> File "/usr/lib/python2.4/logging/__init__.py", line 1328, in shutdown
> for h in _handlerList[:]: # was _handlers.keys():
> TypeError: unsubscriptable object
> Error in sys.exitfunc:
> Traceback (most recent call last):
> File "/usr/lib/python2.4/atexit.py", line 24, in _run_exitfuncs
> func(*targs, **kargs)
> File "/usr/lib/python2.4/logging/__init__.py", line 1328, in shutdown
> for h in _handlerList[:]: # was _handlers.keys():
> TypeError: unsubscriptable object
I've now fixed the logging issue, but what bothers me additionally is the
duplication of tracebacks here. The problem is in atexit._run_exitfuncs:
exc_info = None
while _exithandlers:
func, targs, kargs = _exithandlers.pop()
try:
func(*targs, **kargs)
except SystemExit:
exc_info = sys.exc_info()
except:
import traceback
print >> sys.stderr, "Error in atexit._run_exitfuncs:"
traceback.print_exc()
exc_info = sys.exc_info()
if exc_info is not None:
raise exc_info[0], exc_info[1], exc_info[2]
So the last exception is always reraised and therefore also printed
by call_sys_exitfunc. Is this really wanted behavior?
Georg
More information about the Python-Dev
mailing list