#11345 closed defect (fixed)
AttributeError: NullTranslationsBabel instance has no attribute 'isactive' with Babel 1.3
| Reported by: | Jun Omae | Owned by: | Jun Omae |
|---|---|---|---|
| Priority: | normal | Milestone: | 0.12.6 |
| Component: | i18n | Version: | 1.0.1 |
| Severity: | normal | Keywords: | babel10 |
| Cc: | Branch: | ||
| Release Notes: |
Fix |
||
| API Changes: | |||
| Internal Changes: | |||
Description
Reproduced accessing /about or /prefs/language page if installed Trac 1.0.1 and Babel 1.3 with no compiled catalogs. 0.12-stable has the same issue.
Traceback (most recent call last):
File "/home/jun66j5/src/trac/edgewall/git/trac/web/main.py", line 497, in _dispatch_request
dispatcher.dispatch(req)
File "/home/jun66j5/src/trac/edgewall/git/trac/web/main.py", line 233, in dispatch
content_type)
File "/home/jun66j5/src/trac/edgewall/git/trac/web/chrome.py", line 976, in render_template
data = self.populate_data(req, data)
File "/home/jun66j5/src/trac/edgewall/git/trac/web/chrome.py", line 837, in populate_data
'footer': Markup(footer and translation.gettext(footer))
File "/home/jun66j5/src/trac/edgewall/git/trac/util/translation.py", line 195, in gettext
if not self.isactive:
File "/home/jun66j5/src/trac/edgewall/git/trac/util/translation.py", line 190, in __getattr__
return getattr(self.active, name)
AttributeError: NullTranslationsBabel instance has no attribute 'isactive'
The issue is Translations.add() raises AttributeError: 'NullTranslations' object has no attribute 'add'.
After modified def isactive(self) with the following;
-
trac/util/translation.py
diff --git a/trac/util/translation.py b/trac/util/translation.py index cb9d5db..5e7c0e4 100644
a b try: 175 175 176 176 @property 177 177 def isactive(self): 178 if self._current.args is not None: 179 get_locale, env_path = self._current.args 180 self._current.args = None 181 self.activate(get_locale(), env_path) 182 # FIXME: The following always returns True: either a translation is 183 # active, or activation has failed. 184 return self._current.translations is not None \ 185 or self._activate_failed 178 try: 179 if self._current.args is not None: 180 get_locale, env_path = self._current.args 181 self._current.args = None 182 self.activate(get_locale(), env_path) 183 # FIXME: The following always returns True: either a translation is 184 # active, or activation has failed. 185 return self._current.translations is not None \ 186 or self._activate_failed 187 except AttributeError, e: 188 import sys 189 exc_info = sys.exc_info() 190 raise Exception, unicode(e), exc_info[2] 186 191 187 192 # Delegated methods 188 193
We can retrieve the following traceback.
2013-10-22 23:13:50,205 Trac[main] ERROR: Internal Server Error:
Traceback (most recent call last):
File "/home/jun66j5/src/trac/edgewall/git/trac/web/main.py", line 497, in _dispatch_request
dispatcher.dispatch(req)
File "/home/jun66j5/src/trac/edgewall/git/trac/web/main.py", line 233, in dispatch
content_type)
File "/home/jun66j5/src/trac/edgewall/git/trac/web/chrome.py", line 976, in render_template
data = self.populate_data(req, data)
File "/home/jun66j5/src/trac/edgewall/git/trac/web/chrome.py", line 837, in populate_data
'footer': Markup(footer and translation.gettext(footer))
File "/home/jun66j5/src/trac/edgewall/git/trac/util/translation.py", line 199, in gettext
if not self.isactive:
File "/home/jun66j5/src/trac/edgewall/git/trac/util/translation.py", line 182, in isactive
self.activate(get_locale(), env_path)
File "/home/jun66j5/src/trac/edgewall/git/trac/util/translation.py", line 152, in activate
t.add(Translations.load(locale_dir, locale or 'en_US',
Exception: 'NullTranslations' object has no attribute 'add'
But, if 1.0.2dev (r12205), reproduced only if Accept-Language header is missing or unsupported locale and 2 plugins with catalogs are installed.
Traceback (most recent call last):
File "/home/jun66j5/src/trac/edgewall/git/trac/web/main.py", line 497, in _dispatch_request
dispatcher.dispatch(req)
File "/home/jun66j5/src/trac/edgewall/git/trac/web/main.py", line 233, in dispatch
content_type)
File "/home/jun66j5/src/trac/edgewall/git/trac/web/chrome.py", line 990, in render_template
data = self.populate_data(req, data)
File "/home/jun66j5/src/trac/edgewall/git/trac/web/chrome.py", line 851, in populate_data
'footer': Markup(footer and translation.gettext(footer))
File "/home/jun66j5/src/trac/edgewall/git/trac/util/translation.py", line 200, in gettext
if not self.isactive:
File "/home/jun66j5/src/trac/edgewall/git/trac/util/translation.py", line 182, in isactive
self.activate(get_locale(), env_path)
File "/home/jun66j5/src/trac/edgewall/git/trac/util/translation.py", line 159, in activate
t.add(Translations.load(dirname, locale, domain))
File "/home/jun66j5/venv/py26-babel1/lib/python2.6/site-packages/babel/support.py", line 571, in add
existing.merge(translations)
Exception: 'NullTranslations' object has no attribute 'merge'
Attachments (0)
Change History (6)
comment:1 by , 12 years ago
| Milestone: | next-stable-1.0.x → 0.12.6 |
|---|---|
| Owner: | set to |
| Status: | new → assigned |
comment:2 by , 12 years ago
| Release Notes: | modified (diff) |
|---|---|
| Resolution: | → fixed |
| Status: | assigned → closed |
Committed in [12274] and merged in [12275,12276].
follow-up: 4 comment:3 by , 12 years ago
Just tested out Babel 1.3 and stumbled on this bug.
Now I can only hope that trac 1.0.2 will be released some day :-(
comment:4 by , 12 years ago
Replying to anonymous:
Just tested out Babel 1.3 and stumbled on this bug.
I recommend using Babel 0.9.6 for Trac.
follow-up: 6 comment:5 by , 11 years ago
I have babel 1.3 as well and we got following report: https://josm.openstreetmap.de/ticket/10521 Is this related? It happens when trying to attach something to a wiki page. If yes, I probably need to open a bug for genshi?
comment:6 by , 11 years ago
Replying to dstoecker:
I have babel 1.3 as well and we got following report: https://josm.openstreetmap.de/ticket/10521 Is this related? It happens when trying to attach something to a wiki page. If yes, I probably need to open a bug for genshi?
That seems like an issue in Genshi 0.6.1/0.7 and has been filed in #11184 and genshi:#566. Please try to downgrade to 0.6.0 or use 0.6-stable/0.7-stable branch.



0.12-stable has the same issue with Babel 1.0+.
Proposed fix for 0.12.6 can be found in log:jomae.git:ticket11345_0.12.6dev, for 1.0.2 in log:jomae.git:ticket11345.