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
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
More information about the Python-list
mailing list