'local' object has no attribute 'bindtextdomain' on FreeBSD using Python 2.6.2

Bug #434199 reported by Severin H
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
LottaNZB
Fix Released
Medium
Severin H

Bug Description

Hi, I maintain the lottanzb port on FreeBSD and am trying to update it from 0.4.1 to 0.5.1. When trying to run it I get the following error:

Traceback (most recent call last):
  File "/usr/local/bin/lottanzb", line 6, in <module>
    app = App()
  File "/usr/local/lib/python2.6/site-packages/lottanzb/util.py", line 59, in __call__
    mcs.__instance = GObjectMeta.__call__(mcs, *args, **kwargs)
  File "/usr/local/lib/python2.6/site-packages/lottanzb/core.py", line 114, in __init__
    self.setup_translation()
  File "/usr/local/lib/python2.6/site-packages/lottanzb/core.py", line 138, in setup_translation
    module.bindtextdomain(domain, resources.get_locale())
AttributeError: 'module' object has no attribute 'bindtextdomain'

This is with python 2.6.2. The "module" in question I believe is locale and if I remove it from the list in setup_translation it *seems* to work ok. Any ideas?

Cheers,
Zach

Revision history for this message
Severin H (severinh) wrote :

Hi Zach,

thanks for taking the time to report this. I'm not sure why the "locale" module doesn't have a "bindtextdomain" function on your machine. A quick test revealed that for the UI translation to work 100%, one needs to call the three functions provided by both gettext and locale, otherwise, some menu entries will remain untranslated, which is not that bad. At least it's much better than an application crash. ;-)

I could change the setup_translation method to something like this:

        domain = "lottanzb"

        for module in (gettext, locale):
            try:
                module.bindtextdomain(domain, resources.get_locale())
                module.bind_textdomain_codeset(domain, "UTF-8")
                module.textdomain(domain)
            except AttributeError:
                pass

A fix for this bug will be part of LottaNZB 0.5.2.

Revision history for this message
Severin H (severinh) wrote :

When running an installed LottaNZB, it suffices to run locale.textdomain (because the translation files are in a standardized directory). Would you mind checking if the "locale" module has a "textdomain" function on your system by launching a Python shell using "python" and:

import locale
locale.textdomain

This prints "<built-in function textdomain>" on my system.

Changed in lottanzb:
milestone: none → 0.5.2
assignee: nobody → LottaNZB Development Team (lottanzb)
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
Zach (hideo) wrote :

locale doesn't have textdomain either:

Python 2.6.2 (r262:71600, Sep 21 2009, 10:45:01)
[GCC 4.2.1 20070719 [FreeBSD]] on freebsd7
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.textdomain
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'textdomain'
>>>

Your change to setup_translation did allow it run. Grepping for textdomain in the python install I see that kiwi handles these calls by wrapping them in "if hasattr(locale, ..."

Revision history for this message
Severin H (severinh) wrote :

I guess as FreeBSD's "locale" module doesn't include any of the three methods, we don't need to put an "if hasattr(locale, ..." in front of every statement. "try... except AttributeError" will do just fine.

I'll commit a fix. Thanks again for reporting it!

Severin H (severinh)
Changed in lottanzb:
status: Triaged → Fix Committed
assignee: LottaNZB Development Team (lottanzb) → Severin Heiniger (lantash)
Severin H (severinh)
Changed in lottanzb:
status: Fix Committed → Fix Released
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.