Locale and threads in python 2.1.3 and python 2.2.1
Eugene Morozov
jmv-lists at linux-ink.ru
Tue Apr 1 04:05:31 EST 2003
More information about the Python-list mailing list
Tue Apr 1 04:05:31 EST 2003
- Previous message (by thread): Regular expression help
- Next message (by thread): Catching webbrowser error in RedHat
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello!
Here's a simple example which works correctly when using 2.2.1
interpreter and fails under 2.1.3 (text.lower() result isn't in
accordance with locale):
#######################################
import time, locale
from threading import Thread
from thread import start_new_thread
LOCALE='ru_RU.KOI8-R'
TEXT='????? ? ????'
class TestThread(Thread):
def __init__(self):
Thread.__init__(self)
def run(self):
print 'In thread: %s' % TEXT.lower()
locale.setlocale(locale.LC_ALL, LOCALE)
print 'After setlocale in thread: %s' % TEXT.lower()
print 'Before setlocale: %s' % TEXT.lower()
locale.setlocale(locale.LC_ALL, LOCALE)
print 'After setlocale: %s' % TEXT.lower()
t = TestThread()
t.start()
#######################################
I cannot switch to python 2.2 because 2.1 is still required by Zope.
Does anyone know how to fix that without patching Zope to call
setlocale in every thread?
Eugene
- Previous message (by thread): Regular expression help
- Next message (by thread): Catching webbrowser error in RedHat
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list