Edgewall Software

Ticket #7253 (new enhancement)

Opened 2 months ago

Last modified 13 days ago

Safely disable translations to stop "AttributeError: translations"

Reported by: Pedro Algarvio, aka, s0undt3ch <ufs@…> Owned by: cmlenz
Priority: normal Milestone: 0.12
Component: i18n Version: 0.12dev
Severity: trivial Keywords: verify
Cc:

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

safe.translations.attr.disable.patch (0.5 kB) - added by Pedro Algarvio, aka, s0undt3ch <ufs@…> 2 months ago.
traceback.txt (5.5 kB) - added by Pedro Algarvio, aka, s0undt3ch <ufs@…> 2 months ago.

Change History

Changed 2 months ago by Pedro Algarvio, aka, s0undt3ch <ufs@…>

  Changed 2 months ago by Pedro Algarvio, aka, s0undt3ch <ufs@…>

As a side note, this happens in both 0.11-table and 0.12dev

  Changed 2 months ago by cboos

  • milestone changed from 0.11 to 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?

  Changed 2 months ago by Pedro Algarvio, aka, s0undt3ch <ufs@…>

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

     
    111111        return getattr(_current, 'translations', _null_translations) 
    112112 
    113113    def deactivate(): 
    114         del _current.translations 
     114        if hasattr(_current, 'translations'): 
     115            del _current.translations 
    115116 
    116117    def get_available_locales(): 
    117118        """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 .

  Changed 2 months ago by Pedro Algarvio, aka, s0undt3ch <ufs@…>

  • version changed from 0.11-stable to 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   Changed 2 months ago by 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?

in reply to: ↑ 5   Changed 2 months ago by Pedro Algarvio, aka, s0undt3ch <ufs@…>

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.

Changed 2 months ago by Pedro Algarvio, aka, s0undt3ch <ufs@…>

  Changed 13 days ago by cboos

  • keywords verify added
  • milestone changed from 0.13 to 0.12

I'm still not convinced this can happen in normal use, the plugin must do something quite weird (more info needed).

Add/Change #7253 (Safely disable translations to stop "AttributeError: translations")

Author



Change Properties
<Author field>
Action
as new
as The resolution will be set. Next status will be 'closed'
to The owner will change. Next status will be 'new'
The owner will change to anonymous. Next status will be 'assigned'
 
Note: See TracTickets for help on using tickets.