Modify

Opened 23 months ago

Last modified 23 months ago

#10677 new defect

KeyError: ('add_domain', '_', 'N_', 'tag_')

Reported by: rjollos Owned by: hasienda
Priority: normal Component: AnnouncerPlugin
Severity: normal Keywords: i18n compatibility
Cc: Trac Release: 0.11

Description

When running the unit tests again r8130 of the trunk (which fail for other reasons such as Trac database compatibility), I see the following traceback:

Traceback (most recent call last):
  File "setup.py", line 87, in <module>
    **extra
  File "/usr/lib/python2.7/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/home/user/Workspace/th9110-r8130/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg/setuptools/command/test.py", line 137, in run
    self.with_project_on_sys_path(self.run_tests)
  File "/home/user/Workspace/th9110-r8130/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg/setuptools/command/test.py", line 117, in with_project_on_sys_path
    func()
  File "/home/user/Workspace/th9110-r8130/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg/setuptools/command/test.py", line 146, in run_tests
    testLoader = loader_class()
  File "/usr/lib/python2.7/unittest/main.py", line 94, in __init__
    self.parseArgs(argv)
  File "/usr/lib/python2.7/unittest/main.py", line 149, in parseArgs
    self.createTests()
  File "/usr/lib/python2.7/unittest/main.py", line 158, in createTests
    self.module)
  File "/usr/lib/python2.7/unittest/loader.py", line 128, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib/python2.7/unittest/loader.py", line 91, in loadTestsFromName
    module = __import__('.'.join(parts_copy))
  File "/home/user/Workspace/announcerplugin.git/announcer/tests/__init__.py", line 24, in <module>
    from announcer.tests import (
  File "/home/user/Workspace/announcerplugin.git/announcer/tests/api.py", line 20, in <module>
    from announcer.api import AnnouncementSystem, AnnouncementEvent
  File "/home/user/Workspace/announcerplugin.git/announcer/api.py", line 351, in <module>
    domain_functions('announcer', ('add_domain', '_', 'N_', 'tag_'))
  File "/home/user/Workspace/th9110-r8130/trac-trunk-r8130/trac/util/translation.py", line 91, in domain_functions
    return [_functions[s] for s in symbols]
KeyError: ('add_domain', '_', 'N_', 'tag_')

The fix appears to be:

  • announcer/api.py

    diff --git a/announcer/api.py b/announcer/api.py
    index 69d315b..3c4b1e0 100644
    a b def istrue(value, otherwise=False): 
    348348try: 
    349349    from trac.util.translation import domain_functions 
    350350    add_domain, _, N_ , tag_= \ 
    351         domain_functions('announcer', ('add_domain', '_', 'N_', 'tag_')) 
     351        domain_functions('announcer', 'add_domain', '_', 'N_', 'tag_') 
    352352except ImportError: 
    353353    from  genshi.builder         import  tag as tag_ 
    354354    from  trac.util.translation  import  gettext 

It looks like the reason there is not an error in later versions of Trac is the addition to the top of the function to handle a tuple argument:

    if symbols and not isinstance(symbols[0], basestring):
        symbols = symbols[0]

So the modification to the function call may only be necessary for Trac 0.11 compatibility.

Attachments (0)

Change History (2)

comment:1 Changed 23 months ago by hasienda

  • Keywords i18n compatibility added

I remember that change being made, and the new tuple form becoming the recommended invocation.

For Trac 0.11 this shouldn't be an issue, because all i18n is >= 0.12 only. Anyway, I'll have a look at it and deal with this issue after back-porting db API.

comment:2 Changed 23 months ago by rjollos

Since you are in a try/except, you might be able to deal with the issue by catching KeyError. I briefly tried that and it wasn't working, but didn't dig deeper in why I was running into problems.

Add Comment

Modify Ticket

Action
as new .
Author


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

 
Note: See TracTickets for help on using tickets.