Use of _ without importing it - "NameError: name '_' is not defined"

Bug #1376598 reported by Wlodzimierz Borkowski
This bug report is a duplicate of:  Bug #1323492: Name "_" not defined. Edit Remove
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Triaged
Low
Unassigned

Bug Description

To reproduce start main function in glance/glance/cmd/api.py or glance/glance/cmd/registry.py.
There is exception in devstack:

File "/opt/stack/glance/glance/cmd/api.py", line 28, in <module>
    from glance.common import utils
  File "/opt/stack/glance/glance/common/utils.py", line 45, in <module>
    from glance.common import exception
  File "/opt/stack/glance/glance/common/exception.py", line 30, in <module>
    class GlanceException(Exception):
  File "/opt/stack/glance/glance/common/exception.py", line 38, in GlanceException
    message = _("An unknown exception occurred")
NameError: name '_' is not defined

Process finished with exit code 1

Seems to be similar to bug #885529

I think one of the possible solution (which works for me) is to put in glance/glance/__init__.py lines below:

from glance.openstack.common import gettextutils
gettextutils.install('glance')

Check with glance:2015.1

Changed in glance:
assignee: nobody → Roman Vasilets (rvasilets)
tags: added: low-hanging-fruit
Revision history for this message
Dolph Mathews (dolph) wrote :

Keystone had ongoing issues similar to this, and ultimately moved away from importing gettextutils via entry points (as you're suggesting is the fix here, and will probably work in this one case) to instead do explicit imports into every module where gettextutils is used, which has been much more reliable.

Changed in glance:
importance: Undecided → Low
status: New → Triaged
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to glance (master)

Fix proposed to branch: master
Review: https://review.openstack.org/128657

Changed in glance:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on glance (master)

Change abandoned by Roman Vasilets (<email address hidden>) on branch: master
Review: https://review.openstack.org/128657

Revision history for this message
Ian Cordasco (icordasc) wrote :

Roman abandoned their change so I moved this back to triaged and unassigned them. If you wish to pick this up, please assign yourself. Roman, if you intend to continue working on this re-assign yourself please.

Changed in glance:
status: In Progress → Triaged
assignee: Roman Vasilets (rvasilets) → nobody
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.