Is it possible to reset locale to the portable locale?
Question: According to the Python documentation:

> "a program which has not called `setlocale(LC_ALL, '')` runs using the
> portable 'C' locale.

After having set the locale with `setlocale(LC_ALL, '')` is it possible to
reset the locale back to the "portable" state? I work on a library which
includes some misbehaved components which attempt to globally reset the locale
to the region specific - I need to find a way to revert the locale back to the
portable state.

    
    
    import locale
    loc = locale.getlocale(locale.LC_ALL) # get current locale
    assert loc == (None, None)
    # Locale is unset, therefore in the "portable" state.
    locale.setlocale(locale.LC_ALL, '') # use user's preferred locale
    # Loc is not set to regional default
    ???? DO SOMETHING HERE
    assert loc == locale.getlocale(locale.LC_ALL) # I want to make this true!
    

Needs to work on Python 2.4.4 on Windows XP 32bit


Answer: You could try: `locale.setlocale(locale.LC_ALL, loc)`.

    
    
    >>> locale.getlocale(locale.LC_ALL)
    (None, None)
    >>> locale.setlocale(locale.LC_ALL, "")                                        
    'en_US.utf8'
    >>> locale.getlocale(locale.LC_ALL)
    ('en_US', 'UTF8')
    >>> locale.setlocale(locale.LC_ALL, "C")                                   
    'C'
    >>> locale.getlocale(locale.LC_ALL)
    (None, None)
    >>> locale.setlocale(locale.LC_ALL, (None,None))
    'C'
    >>> locale.getlocale(locale.LC_ALL)
    (None, None)
    

