Error setting locale in python

Harald Hanche-Olsen hanche at math.ntnu.no
Thu Jul 22 11:32:06 PDT 2010


python2.5 and python2.6 both don't like my locale setting:

  ; python2.6
  Python 2.6.5 (r265:79063, Jul 16 2010, 21:35:10) 
  [GCC 4.0.1 (Apple Inc. build 5493)] on darwin
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import locale
  >>> locale.setlocale(locale.LC_ALL,'')
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/locale.py", line 513, in setlocale
      return _setlocale(category, locale)
  locale.Error: unsupported locale setting

/usr/bin/python, on the other hand, has no such problems.
My locale setting may be a bit unusual, but not illegal AFAIK:

  ; locale
  LANG=
  LC_COLLATE="C"
  LC_CTYPE="en_US.UTF-8"
  LC_MESSAGES="C"
  LC_MONETARY="C"
  LC_NUMERIC="C"
  LC_TIME="C"
  LC_ALL=

Any suggestions? Is this a bug, or am I actually not allowed to
specify my locale that way?

- Harald


More information about the macports-users mailing list