[Python-bugs-list] [ python-Bugs-500595 ] gettext.install behaves strange

noreply@sourceforge.net noreply@sourceforge.net
Mon, 07 Jan 2002 13:32:20 -0800


Bugs item #500595, was opened at 2002-01-07 13:32
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=500595&group_id=5470

Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Sebastian Rittau (srittau)
Assigned to: Nobody/Anonymous (nobody)
Summary: gettext.install behaves strange

Initial Comment:
This is a copy of a bug I sent to the Debian BTS (bug
number #127954):

---------------------------------------

The behaviour of the gettext.install function is broken
in Python 2.1 as
well as 2.2. Whenever it tries to open a message
catalog that does not
exist, an exception is thrown and _ does not get
installed in the
standard namespace. Consider:

srittau@jroger:~$ python
Python 2.1.1 (#1, Nov 11 2001, 18:19:24)
[GCC 2.95.4 20011006 (Debian prerelease)] on linux2
Type "copyright", "credits" or "license" for more
information.
>>> import gettext
>>> gettext.install('foo')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.1/gettext.py", line 251, in
install
    translation(domain, localedir).install(unicode)
  File "/usr/lib/python2.1/gettext.py", line 238, in
translation
    raise IOError(ENOENT, 'No translation file found
for domain', domain)
IOError: [Errno 2] No translation file found for
domain: 'foo'
>>> 

This does even happen if I set LANG to C!

Now, I would expect python to continue if a message
catalog is not
found, as does every other program I know of. A missing
catalog is
certainly not a critical error. It should at least
install _ in the
standard name space and throw a custom exception that I
can easily
ignore if the catalog was not found.

I can workaround this behaviour by catching the IOError
exception and
installing _ in the standard name space by hand. But
that's certainly
not the solution. 

---------------------------------------

The Debian maintainer suggested that I bring this up
here. He also believes that this is a documentation
bug, since this behaviour is documented for
gettext.translation(), but not for gettext.install().
But I still believe that this behaviour is wrong, since
not finding a translation file is the common case and
you will want to continue to use your program and just
use the internal strings.

 - Sebastian

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=500595&group_id=5470