Opened 10 years ago

Closed 10 years ago

# [PATCH] Compatibility for Python 2.3

Reported by: Owned by: coroner coderanger normal TicketDeletePlugin normal 0.9

### Description

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)
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.

### Changed 10 years ago by coroner

Backward compatibility patch for Python 2.3 as explained in the ticket

### Changed 10 years ago by coroner

Backward compatibility patch for Python 2.3 as explained in the ticket (second try)

### comment:1 Changed 10 years ago by coroner

Just noticed that the first version had a typo inside - strange enough this did not show up when I tried the modified plugin.

Another issue I now see: whenever I try to delete one or more changes (number doesn't count) to a ticket via the "delete checked" button, I get:

Timestamp 'None' not valid


Deleting changes/fields one-by-one with the corresponding buttons in the last column works fine, though.

### comment:2 Changed 10 years ago by coroner

Hmm... strange enough I'm not able to reproduce the problem mentioned at the end of my last comment now. Seems to be unrelated to the patch anyway. Forget about that, I'm trying to investigate that further.

### comment:3 Changed 10 years ago by coroner

• Resolution set to fixed
• Status changed from new to closed

Fixed in r797 and r798.