#7253 closed enhancement (fixed)
Safely disable translations to stop "AttributeError: translations"
Reported by: | Owned by: | Christian Boos | |
---|---|---|---|
Priority: | high | Milestone: | 0.12 |
Component: | i18n | Version: | 0.12dev |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
Although this was found while working on a plugin, this could be avoided.
If one raises RequestDone
too soon for a translation to be activated, one get's an AttributeError
and this could be avoided by first checking if there's actually a translations
attribute prior to deleting it.
A patch follows.
Attachments (2)
Change History (15)
by , 17 years ago
Attachment: | safe.translations.attr.disable.patch added |
---|
comment:1 by , 17 years ago
comment:2 by , 17 years ago
Milestone: | 0.11 → 0.12 |
---|
I doubt this could happen in 0.11-stable, as there's no deactivate()
there.
About 0.12dev, was the problem happening even with r7051?
comment:3 by , 17 years ago
Replying to cboos:
I doubt this could happen in 0.11-stable, as there's no
deactivate()
there. About 0.12dev, was the problem happening even with r7051?
On the branch I currently have:
-
trac/util/translation.py
111 111 return getattr(_current, 'translations', _null_translations) 112 112 113 113 def deactivate(): 114 del _current.translations 114 if hasattr(_current, 'translations'): 115 del _current.translations 115 116 116 117 def get_available_locales(): 117 118 """Return a list of locale identifiers of the locales for which
And so that you know my branch:
svn info Path: . URL: http://svn.edgewall.org/repos/trac/branches/0.11-stable Repository Root: http://svn.edgewall.org/repos/trac Repository UUID: af82e41b-90c4-0310-8c96-b1721e28e2e2 Revision: 7072 Node Kind: directory Schedule: normal Last Changed Author: nkantrowitz Last Changed Rev: 7071 Last Changed Date: 2008-05-16 10:19:19 +0100 (Fri, 16 May 2008)
So, it is present on 0.11-stable or am I lost somewhere?
Regarding 0.12dev on r7051, yes, the symptom also shows up as on r7087 .
comment:4 by , 17 years ago
Version: | 0.11-stable → 0.12dev |
---|
Sorry, after switching again to the stable branch, I say you're right cboos, it does not happen on the 0.10-stable branch.
follow-up: 6 comment:5 by , 17 years ago
Well, never trust your working copy, use Trac :-) source:branches/0.11-stable/trac/util/translation.py
Ok, thanks for the confirmation that r7051 was not enough. Could you eventually post the full backtrace from the log?
comment:6 by , 17 years ago
Replying to cboos:
Well, never trust your working copy, use Trac :-) source:branches/0.11-stable/trac/util/translation.py
Ok, thanks for the confirmation that r7051 was not enough. Could you eventually post the full backtrace from the log?
Sure but this was thrown when developing a plugin, normal use of trac does not seem to throw it. Anyway, attaching the traceback.
by , 17 years ago
Attachment: | traceback.txt added |
---|
comment:7 by , 16 years ago
Keywords: | verify added |
---|---|
Milestone: | 0.13 → 0.12 |
I'm still not convinced this can happen in normal use, the plugin must do something quite weird (more info needed).
comment:8 by , 16 years ago
Still happens on [7409]:
127.0.1.1 - - [27/Jul/2008 16:35:21] "GET / HTTP/1.1" 500 - 16:35:21 Trac[main] DEBUG: 304 unreachable objects found. 16:35:23 Trac[main] DEBUG: Dispatching <Request "GET u'/'"> 16:35:23 Trac[session] DEBUG: Retrieving session for ID '4200ddb5e6bbb59fae27136b' 16:35:23 Trac[main] ERROR: translations Traceback (most recent call last): File "/home/vampas/projects/HGTrac/trac/web/main.py", line 447, in _dispatch_request dispatcher.dispatch(req) File "/home/vampas/projects/HGTrac/trac/web/main.py", line 257, in dispatch translation.deactivate() File "/home/vampas/projects/HGTrac/trac/util/translation.py", line 114, in deactivate del _current.translations AttributeError: translations
The only plugins activated are mercurial support and account manager; actually, with all plugins disabled it still happens.
I also get on browser:
Traceback (most recent call last): File "/home/vampas/projects/HGTrac/trac/web/api.py", line 344, in send_error data, 'text/html') File "/home/vampas/projects/HGTrac/trac/web/chrome.py", line 699, in render_template data = self.populate_data(req, data) File "/home/vampas/projects/HGTrac/trac/web/chrome.py", line 637, in populate_data 'locale': req and req.locale, File "/home/vampas/projects/HGTrac/trac/web/api.py", line 170, in __getattr__ value = self.callbacks[name](self) File "/home/vampas/projects/HGTrac/trac/web/main.py", line 281, in _get_locale return Locale.negotiate(preferred, available, sep='-') File "/home/vampas/projects/Babel/babel/core.py", line 181, in negotiate aliases=aliases) File "/home/vampas/projects/Babel/babel/core.py", line 699, in negotiate_locale ll = locale.lower() AttributeError: 'list' object has no attribute 'lower'
Hmm, and this last one brings babel into the equation :\
comment:9 by , 16 years ago
Sorry, this was trigged by a not that related bug found #7469.
Once fix is applied, the above no longer happens.
comment:10 by , 16 years ago
Milestone: | 0.12 |
---|---|
Resolution: | → worksforme |
Status: | new → closed |
OK, #7469 is fixed, closing this one as well.
comment:11 by , 15 years ago
Keywords: | verify removed |
---|---|
Milestone: | → 0.12 |
Priority: | normal → high |
Resolution: | worksforme |
Severity: | trivial → normal |
Status: | closed → reopened |
Still happens at times. Here's the last I got:
Exception happened during processing of request from ('127.0.0.1', 52117) Traceback (most recent call last): File "C:\Dev\Python261\lib\SocketServer.py", line 559, in process_request_thread self.finish_request(request, client_address) File "C:\Dev\Python261\lib\SocketServer.py", line 320, in finish_request self.RequestHandlerClass(request, client_address, self) File "C:\Dev\Python261\lib\SocketServer.py", line 616, in __init__ self.handle() File "C:\Dev\Python261\lib\BaseHTTPServer.py", line 342, in handle self.handle_one_request() File "C:\Workspace\src\trac\repos\trunk\trac\web\wsgi.py", line 187, in handle_one_request gateway.run(self.server.application) File "C:\Workspace\src\trac\repos\trunk\trac\web\wsgi.py", line 88, in run response = application(self.environ, self._start_response) File "trac/web/standalone.py", line 58, in __call__ return self.application(environ, start_response) File "trac/web/standalone.py", line 100, in __call__ return self.application(environ, start_response) File "C:\Workspace\src\trac\repos\trunk\trac\web\main.py", line 438, in dispatch_request translation.deactivate() File "C:\Workspace\src\trac\repos\trunk\trac\util\translation.py", line 253, in deactivate translations.deactivate() File "C:\Workspace\src\trac\repos\trunk\trac\util\translation.py", line 135, in deactivate del self._current.translations AttributeError: translations
(seen in the trac.log only, so it must have been for a secondary request)
comment:12 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Should be fixed by r8496.
comment:13 by , 15 years ago
Owner: | changed from | to
---|
As a side note, this happens in both
0.11-table
and0.12dev