gettext_po_exporter refactoring gone wrong

Bug #618576 reported by Данило Шеган
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
Critical
Jeroen T. Vermeulen

Bug Description

The recent small refactoring we did for translations has one big problem: it doesn't always work. I am surprised it works at all, but here's the traceback we get (https://pastebin.canonical.com/35859/):

2010-08-16 09:31:18 DEBUG Exporting objects for Данило Шеган, related to template scinotes in Scilab trunk
2010-08-16 09:32:23 DEBUG Removing lock file: /var/lock/launchpad-rosetta-export-queue.lock
Traceback (most recent call last):
  File "cronscripts/rosetta-export-queue.py", line 23, in <module>
    script.lock_and_run()
  File "/srv/staging.launchpad.net/staging/launchpad/lib/lp/services/scripts/base.py", line 285, in lock_and_run
    implicit_begin=implicit_begin, isolation=isolation)
  File "/srv/staging.launchpad.net/staging/launchpad/lib/lp/services/scripts/base.py", line 243, in run
    self.main()
  File "cronscripts/rosetta-export-queue.py", line 18, in main
    process_queue(self.txn, self.logger)
  File "/srv/staging.launchpad.net/staging/launchpad/lib/lp/translations/scripts/po_export_queue.py", line 385, in process_queue
    process_request(person, objects, format, logger)
  File "/srv/staging.launchpad.net/staging/launchpad/lib/lp/translations/scripts/po_export_queue.py", line 336, in process_request
    target_format=format)
  File "/srv/staging.launchpad.net/staging/launchpad/lib/lp/translations/utilities/translation_export.py", line 97, in exportTranslationFiles
    force_utf8=force_utf8)
  File "/srv/staging.launchpad.net/staging/launchpad/lib/lp/translations/utilities/gettext_po_exporter.py", line 377, in exportTranslationFile
    file_path, file_extension, encoded_file_content, mime_type)
UnboundLocalError: local variable 'encoded_file_content' referenced before assignment

The problem seems to be simple: encoded_file_content is referenced outside the for loop, and yet it's constructed inside the for loop. FWIW, the loop is over translation messages, so encoded_file_content should be outside the loop as well. It's a miracle this has passed our test suite.

Revision history for this message
Данило Шеган (danilo) wrote :

I believe the fix is just de-indenting all the code after exported_file_content assignment until storage.addFile call. I've just tested that on staging.

However, we do need tests for this!

Changed in rosetta:
status: Triaged → In Progress
Changed in rosetta:
assignee: nobody → Jeroen T. Vermeulen (jtv)
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

The fix is in devel r11350 and production-devel r9651.

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

The fix is now also in db-devel 9659.

Revision history for this message
Launchpad QA Bot (lpqabot) wrote : Bug fixed by a commit
tags: added: qa-needstesting
Revision history for this message
Sylvestre Ledru (sylvestre) wrote :

I can test for Scilab when it is available on a launchpad instance.

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Our inimitable Tom Haddon is rolling it out right now.

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

It is done. Sylvestre, please go ahead and let us know!

Revision history for this message
Sylvestre Ledru (sylvestre) wrote :

Looks life perfect. I have been able to download all templates and it is working fine.

Thanks for your quick reactivity.

Revision history for this message
Sylvestre Ledru (sylvestre) wrote :

(to me, this bug is fixed)

Changed in rosetta:
status: In Progress → Fix Released
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Sylvestre, thanks again for your help.

tags: added: qa-ok
removed: qa-needstesting
Revision history for this message
costales (costales) wrote :

Hi! :)
This bug persist for me: https://bugs.launchpad.net/rosetta/+bug/617431
I can't download the .mo files. I don't know if is another issue.
Best regards and thanks.

Revision history for this message
Данило Шеган (danilo) wrote :

Marcos: yeah, we noticed, which is why we "unduplicated" it. Jeroen already mentioned a workaround there (you can download PO files and convert them to MO files yourself using "msgfmt" from gettext-tools), but we should be fixing it shortly.

Revision history for this message
costales (costales) wrote :

I'm sorry :$ Thanks for the explanation Данило Шеган :)

Revision history for this message
Данило Шеган (danilo) wrote :

Oh, sorry if I came up negative :) We actually appreciate your input, and that prompted me to check if MO exports are working after a fix. Anyway, I was just trying to say that we are already working on fixing it! FWIW, even I can't tell easily that the bug was "unduplicated" from looking at this page, which is probably a problem we should solve as well ;)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.