Modify

Opened 5 months ago

Closed 5 months ago

Last modified 5 months ago

#13027 closed defect (fixed)

[patch] MilestoneTemplates: fix error 'ImportError: cannot import name _' for trac 1.2

Reported by: komar Owned by: komar
Priority: normal Component: MilestoneTemplatePlugin
Severity: normal Keywords:
Cc: Trac Release:

Description

After upgrading trac to 1.2 I get error:

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/trac/loader.py", line 68, in _load_eggs
    entry.load(require=True)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2291, in load
    return self.resolve()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2297, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python2.7/dist-packages/milestonetemplate/web_ui.py", line 10, in <module>
    from trac.util.text import _
ImportError: cannot import name _

there is a patch

--- a/web_ui.py        2017-01-04 16:06:01.733012868 +0100
+++ b/web_ui.py        2017-01-04 16:06:07.000000000 +0100
@@ -7,7 +7,7 @@
 from trac.ticket.admin import MilestoneAdminPanel
 from trac.ticket.model import Milestone
 from trac.util.datefmt import parse_date
-from trac.util.text import _
+from trac.util.translation import _
 from trac.web.api import IRequestFilter
 from trac.web.chrome import add_notice, add_script, add_script_data, add_stylesheet, \
     ITemplateProvider, ITemplateStreamFilter

Attachments (0)

Change History (2)

comment:1 Changed 5 months ago by Ryan J Ollos

Resolution: fixed
Status: newclosed

In 16172:

MilestoneTemplatePlugin 0.1.2: Fix incorrect import

Patch by komar.

Fixes #13027.

comment:2 Changed 5 months ago by Ryan J Ollos

Owner: changed from Cinc-th to komar

The fix was straightforward, so I took the liberty to push it. I hope that is okay.

The _ function has always been in the module trac.util.translation, so I imagine this only worked in Trac 1.0.x due to a transitive import.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain komar.
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.