Modify

Opened 11 years ago

Closed 11 years ago

#399 closed enhancement (fixed)

[PATCH] Compatibility for Python 2.3

Reported by: Mike's Testaccount Owned by: Noah Kantrowitz
Priority: normal Component: TicketDeletePlugin
Severity: normal Keywords:
Cc: Trac Release: 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)
  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.

Attachments (2)

python-2.3-compatibility.diff (648 bytes) - added by Mike's Testaccount 11 years ago.
Backward compatibility patch for Python 2.3 as explained in the ticket
python-2.3-compatibility-2.diff (648 bytes) - added by Mike's Testaccount 11 years ago.
Backward compatibility patch for Python 2.3 as explained in the ticket (second try)

Download all attachments as: .zip

Change History (5)

Changed 11 years ago by Mike's Testaccount

Backward compatibility patch for Python 2.3 as explained in the ticket

Changed 11 years ago by Mike's Testaccount

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

comment:1 Changed 11 years ago by Mike's Testaccount

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 11 years ago by Mike's Testaccount

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 11 years ago by Mike's Testaccount

Resolution: fixed
Status: newclosed

Fixed in r797 and r798.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Noah Kantrowitz.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.