locale setting fails on Mac OS X

Bug #666265 reported by Tim Radvan
4
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pylinkgrammar
New
Undecided
Unassigned

Bug Description

When initialising the lp() class on Mac OS, the locale setting fails.

I compiled link-grammar and the python bindings by following the instructions in the FAQ here: https://answers.launchpad.net/pylinkgrammar/+faq/336

Here is the output of the example script:
$ python example1.py
Traceback (most recent call last):
  File "example1.py", line 2, in <module>
    parser = lp()
  File "/Users/tim/Code/build/linkgrammar.py", line 8, in __init__
    locale.setlocale(locale.LC_ALL,"en_US.UTF8")
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/locale.py", line 494, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting
Cleaning up linkgrammar...
Deleting <class 'linkgrammar.lp'>
Exception AttributeError: 'parse_options' in <bound method lp.__del__ of <linkgrammar.lp object at 0x10049ce10>> ignored

I fixed the problem by enclosing the locale setting in a try block as follows:
try:
    locale.setlocale(locale.LC_ALL,"en_US.UTF8")
except Exception, e:
    print 'Could not set locale:', e

The program then runs and parses the sentence correctly, but gives the output:
Could not set locale: unsupported locale setting

The problem disappears completely if the line is changed to:
locale.setlocale(locale.LC_ALL,"")

I don't really know what this line does, but should it be fixed some other way?

If this is a problem with my setup or you don't consider this a bug, please convert it to a question or delete it as necessary. I'm using Mac OS X 10.6.4.
Thanks!

Related branches

Tim Radvan (blob8108)
description: updated
description: updated
Tim Radvan (blob8108)
description: updated
Tim Radvan (blob8108)
description: updated
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.