[Python-3000] setup.py fails in the py3k-struni branch

Ron Adam rrr at ronadam.com
Fri Jun 8 01:20:23 CEST 2007


Martin v. Löwis wrote:

> FWIW, for me the build error goes away when I unset
> LANG, so that the error occurs during build definitely
> *is* a locale issue.

Yes, and to pin it down a bit further...

This avoids the problem by setting the language to the default "C" which is 
a unicode string and has a .split method that accepts 0 args.

Also LANG is 4th on the list of possible language setting sources, so if 
one of the other 3 environment variables is set, setting or unsetting LANG 
will have no effect.


--- From gettext.py ---

# Locate a .mo file using the gettext strategy
def find(domain, localedir=None, languages=None, all=0):
     # Get some reasonable defaults for arguments that were not supplied
     if localedir is None:
         localedir = _default_localedir
     if languages is None:
         languages = []
         for envar in ('LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG'):
                       # ^^^  first one is accepted.
             val = os.environ.get(envar)      #<<< should return unicode?
             if val:
                 languages = val.split(':')
                 break
         if 'C' not in languages:
             languages.append('C')                     # <<< unicode 'C'
     # now normalize and expand the languages
     nelangs = []
     for lang in languages:
         for nelang in _expand_lang(lang):    #<<< error in this call
                                              #    when it's normalized.
             if nelang not in nelangs:
                 nelangs.append(nelang)

------

Guido's patch avoids this, but that fix was also needed as unicode 
translate works differently than str.translate.

The os.environ.get() method probably should return a unicode string. (?)

Ron




More information about the Python-3000 mailing list