[Python-Dev] 2.5: uses of sys.exc_type, exc_value

A.M. Kuchling amk at amk.ca
Wed Jul 26 19:58:24 CEST 2006


http://www.python.org/sf/1525469 reports that SimpleXMLRPCServer.py
still uses sys.exc_type and sys.exc_value when handling exceptions.
These variables aren't thread-safe and sys.exc_info() is the better
way.  I have a patch attached to the bug that fixes the problem.

Question 1: is this worth fixing for 2.5?  (It's not really a bugfix,
more of a style cleanup.)

Question 2: I searched for uses of the old variables and found these:

Lib/idlelib/WindowList.py:                      sys.exc_type, ":", sys.exc_value
Lib/logging/__init__.py:        return sys.exc_traceback.tb_frame.f_back
Lib/lib-tk/Tkinter.py:        exc, val, tb = sys.exc_type, sys.exc_value, sys.exc_traceback
Lib/plat-mac/cfmfile.py:                    raise Res.Error, "no 'cfrg' resource found", sys.exc_traceback
Lib/SocketServer.py:            sys.exc_traceback = None    # Help garbage collection

Plus some references in the test suite, the demos, and faqwizard.py.

SocketServer should use sys.exc_clear() instead.  Tkinter.py could
just call exc_info(), but I wonder if the usage of the variables is
intentional here.  sys.exc_info() was introduced in Python 1.5, so
logging/__init__.py could be fixed without affecting 1.5.2
compatibility.

Should the above uses be fixed, too?  

--amk


More information about the Python-Dev mailing list