[PATCH] Compatibility for Python 2.3
|Reported by:||mrenzmann@…||Owned by:||coderanger|
My server runs with Python 2.3 (mod_python and Apache2). When I tried to delete a comment to a ticket, I saw the following error message:
Oops... Trac detected an internal error: 'module' object has no attribute 'format_exc' [...] Python traceback Traceback (most recent call last): File "/usr/lib/python2.3/site-packages/trac/web/modpython_frontend.py", line 206, in handler dispatch_request(mpr.path_info, mpr, env) File "/usr/lib/python2.3/site-packages/trac/web/main.py", line 139, in dispatch_request dispatcher.dispatch(req) File "/usr/lib/python2.3/site-packages/trac/web/main.py", line 107, in dispatch resp = chosen_handler.process_request(req) File "/usr/src/trac/webadmin/webadmin/web_ui.py", line 106, in process_request path_info) File "/usr/src/trac/ticketdeleteplugin-0.9/ticketdelete/web_ui.py", line 67, in process_admin_request self.log.debug(traceback.format_exc()) AttributeError: 'module' object has no attribute 'format_exc'
cmlenz pointed out that format_exc has been introduced in Python 2.3, and that changing the offending line slightly should fix the problem. His suggestion was:
09:42:04 < cmlenz> format_exc() is new in python2.4 IIRC 09:42:26 < otaku42> cmlenz: so python 2.3 is not sufficient in this case? 09:42:50 < cmlenz> no, but that's probably just an oversight 09:43:40 < otaku42> cmlenz: do you know of an easy way to work around this (given that i can not upgrade to python 2.4 - still need to check that)? 09:44:22 < cmlenz> also unnecessary: just replace the offending line with "self.log.debug('Something wrong', exc_info=True)"
The attached patch implements this suggestion, and the error now is gone. Anyway, I'm a Python noob and am not aware if the change I did is exactly what coderanger intended. However I think it points in the right direction.