Opened 8 years ago

Closed 8 years ago

FullBlog broken with 0.12dev

Reported by: Owned by: jouvin@… Odd Simon Simonsen normal FullBlogPlugin normal 0.12

Description

Hi,

I tried to use FullBlog with current Trac trunk (0.12dev-7795) but it fails because it relies on a compatibility function, itemgetter, that was marked for removal in 0.11 and removed in 0.12...

An easy workaround is to copy itemgetter from 0.11 (trac/util/compat.py) but a cleaner fix is probably needed...

Michel

comment:1 follow-up:  4 Changed 8 years ago by Odd Simon Simonsen

Seeing 0.12 marks the end-of-line for Python 2.3 support, this compat import is no longer needed - and should just import itemgetter directly like from operator import itemgetter.

I'll get around to making a 0.12 branch at some stage.

comment:2 follow-up:  3 Changed 8 years ago by jouvin@…

BTW, there is the same issue in FullBlogNotifier.

Michel

comment:3 in reply to:  2 Changed 8 years ago by Odd Simon Simonsen

BTW, there is the same issue in FullBlogNotificationPlugin.

And no doubt many others as well that depend on the compat that was yanked away from Trac trunk... That notification plugin isn't mine, so if you find issues with it then please report it in new tickets.

comment:4 in reply to:  1 Changed 8 years ago by anonymous

it works fine! THX.

Changed 8 years ago by shookie@…

removes the compat imports that are not needed anymore in trac 0.12

Changed 8 years ago by shookie@…

removes the compat imports that are not needed anymore in trac 0.12

comment:5 Changed 8 years ago by shookie@…

All that is really needed is to remove the imports and it works fine.

Regards

Changed 8 years ago by shookie

stupid error in forgetting to import the python builtin itemgetter

comment:6 Changed 8 years ago by shookie@…

sorry for inconvinience, but the third attachment is the proper diff. The first two are the same, but won't work.

comment:7 Changed 8 years ago by Odd Simon Simonsen

Sorry, can't use operator.itemgetter() as that was added in Python 2.4 - Trac 0.11.x is still fully Python 2.3 compatible, and that compat fix would likely lead to all sorts of new issues. I'll happily apply any fix that works for Trac 0.11+ and Python 2.3+.

comment:8 Changed 8 years ago by Odd Simon Simonsen

I'm not all that keen on branching the plugin for 0.12 yet - it increases maintenance for a long time. A workaround may be to try to do the import from trac.util.compat and if they fail (ie. ImportError with Trac 0.12) then proceed to import itemgetter. That should make everyone happy, I think.

comment:9 Changed 8 years ago by Odd Simon Simonsen

Could you perhaps try something this in the two files:

try:
from trac.util.compat import itemgetter
from trac.util.compat import sorted, set
except ImportError:
# 0.12 compat - sorted and set should already be part of Python 2.4
from operator import itemgetter


I'll also need to test that on 0.11 before committing, but I'll get that done when I'm back on my dev machine.

Changed 8 years ago by shookie@…

tried it, works, diff attached that works for 0.11 and 0.12

comment:10 Changed 8 years ago by Odd Simon Simonsen

Resolution: → fixed new → closed

Fix committed in [6158]. Thanks!

Modify Ticket

Change Properties