From: Charlie G. <cha...@gm...> - 2008-11-09 18:48:00
|
On Thu, Nov 6, 2008 at 2:39 PM, ag356 <ge...@mi...> wrote: > > Hi. Can anyone tell me why the following does not work? > > == Begin > > import org.python.util.PythonInterpreter; > > public class test { > > public static void main(String[] args) throws Exception { > for (int i = 0; i < 10; i++) { > new Thread () { > public void run () { > String code = "s = \"Hello " + > Thread.currentThread().getName() + > "\"\nb = unicode(s,\"utf-8\")\nprint b\n"; > System.out.println("code:\n"+code); > PythonInterpreter interp = new PythonInterpreter(); > interp.exec(code); > } > }.start(); > } > } > > } > > == End > > I get "LookupError: no codec search functions registered: can't find > encoding" for usually all but one of the threads. Sometimes two or three of > them work. > > If I add "import encodings" to the beginning of the script then it works. Looks like we're not synchronizing properly when initializing the codec lookup in org.python.core.codecs. I've opened http://bugs.jython.org/issue1169 to track hunting this down. I imagine this is something we'll take care of before releasing 2.5, but I'm not sure how long it will be before someone really takes a look at it. Charlie |