From: Jim B. <jim...@py...> - 2016-01-12 03:33:18
|
Yaqiang, Sounds good about your progress. I'm looking forward to your changes landing in Jython 2.7.2, which we will finally have a chance to work on quite soon now that we are almost done with beta 3 work. I suggest that you organize your changes as either a diff that you add to a bug or equivalently a pull request against https://github.com/jythontools/jython Otherwise it's very challenging for us to review your changes, although the basic outline of what you have done looks good. The other challenge will be to come up with good unit tests so we can verify your fixes. In general, Py.newStringOrUnicode() usually works, because Python 2.7 - and consequently, Jython 2.7 as an implementation - is loose about it works with str and unicode objects and their combination. (Making this more strict is one of the biggest changes in Python 3.) However, I do know that one bug you might encounter, http://bugs.jython.org/issue2295, is going to be hard for us to fix. - Jim On Sat, Jan 9, 2016 at 1:38 AM, yaq...@gm... < yaq...@gm...> wrote: > Jim, > > I have tried revised some code of Jython as below: > > PySystemState.java > > private static void initRegistry(Properties preProperties, Properties postProperties, > boolean standalone, String jarFileName) > PySystemState.prefix = Py.newString(prefix); > to > PySystemState.prefix = Py.newStringOrUnicode(prefix); > > PySystemState.exec_prefix = Py.newString(exec_prefix); > to > PySystemState.exec_prefix = Py.newStringOrUnicode(exec_prefix); > > private static void addPaths(PyList path, String pypath) > path.append(new PyString(tok.nextToken().trim())); > to > path.append(Py.newStringOrUnicode(tok.nextToken().trim())); > > > private static PyList initPath(Properties props, boolean standalone, String jarFileName) > path.append(new PyString(libpath)); > to > path.append(Py.newStringOrUnicode(libpath)); > > PyObject.java > public PyObject __finditem__(String key) > return __finditem__(new PyString(key)); > to > return __finditem__(Py.newStringOrUnicode(key)); > > public void __setitem__(String key, PyObject value) > __setitem__(new PyString(key), value); > to > __setitem__(Py.newStringOrUnicode(key), value); > > zipimporter.java > private void readZipFile(ZipFile zipFile, PyObject files) > PyObject __file__ = new PyString(archive + File.separator + name); > to > PyObject __file__ = Py.newStringOrUnicode(archive + File.separator + name); > > files.__setitem__(new PyString(name), entry); > to > files.__setitem__(Py.newStringOrUnicode(name), entry); > > imp.java > > public static PyObject createFromCode(String name, PyCode c, String moduleLocation) > module.__setattr__("__file__", new PyString(moduleLocation)); > to > module.__setattr__("__file__", Py.newStringOrUnicode(moduleLocation)); > > Now Jython can be initialized with non-ASCII (such as Chinese) characters > in the path. There is still a problem that the Jython module can not be > loaded with non-ASCIIcharacters path. I don't know how to fix it. Can you > give me some clues on it? Thanks. > > Regards > Yaqiang > ------------------------------ > ************************************************* > Dr. Yaqiang Wang > Chinese Academy of Meteorological Sciences (CAMS) > 46, Zhong-Guan-Cun South Avenue > Beijing, 100081 > China > > yaq...@gm... > > http://www.meteothinker.com > *https://www.researchgate.net/profile/Yaqiang_Wang5 > <https://www.researchgate.net/profile/Yaqiang_Wang5>* > ************************************************** > > > *From:* Jim Baker <jim...@py...> > *Date:* 2016-01-09 11:36 > *To:* yaq...@gm... > *CC:* jython-users <jyt...@li...>; Jython Developers > <jyt...@li...> > *Subject:* Re: Re: [Jython-users] How to build Jython standalone jar from > source code > Yaqiang, > > I believe that bug was fixed related to sockets was most likely fixed, but > we have other issues where Java is using Unicode, but Python wants a str > (which is just bytes). So we see it in the somewhat related bugs > http://bugs.jython.org/issue2369 and http://bugs.jython.org/issue2293 > (possibly others). > > I think the only way we are going to solve this problem is for one of us > developers to attempt to do everything using a username/home directory that > does not use ascii. Otherwise we are just doing piecemeal fixes. > > - Jim > > On Fri, Jan 8, 2016 at 8:06 PM, yaq...@gm... < > yaq...@gm...> wrote: > >> Dear jim, >> >> I have built Jython standalone jar for version 2.7.1b2 succesfully using >> 'ant all-jars' command with Java 7. But I still have below problem with >> newest Jython version. >> >> I am developing MeteoInfoLab software using Java and Jython (as script >> language). It's ok to initialize Jython when the directory path only >> includes ASCII characters. But the initialization will be failed if the >> path includes non-ASCII characters (in my case is Chinese characters). The >> error message shows: java.lang.IllegalArgumentException: Cannot create PyString with non-byte value. >> The issue 2331 said it has been solved in 2.7.1b2 ( >> http://bugs.jython.org/issue2331) , but the problem is still there from >> my test. I also mentioned that a comment report same problem in github ( >> https://github.com/jythontools/jython/commit/c61eaefb774cdb174472265d3c27fc5b87febd34 >> ). >> >> The detailed error message: >> >> java.lang.IllegalArgumentException: Cannot create PyString with non-byte value >> at org.python.core.PyString.<init>(PyString.java:64) >> at org.python.core.PyString.<init>(PyString.java:70) >> at org.python.core.Py.newString(Py.java:645) >> at org.python.core.PySystemState.initRegistry(PySystemState.java:795) >> at org.python.core.PySystemState.doInitialize(PySystemState.java:1040) >> at org.python.core.PySystemState.initialize(PySystemState.java:969) >> at org.python.core.PySystemState.initialize(PySystemState.java:925) >> at org.python.core.PySystemState.initialize(PySystemState.java:920) >> at org.python.core.PySystemState.initialize(PySystemState.java:915) >> at org.python.core.PySystemState.initialize(PySystemState.java:911) >> >> at org.python.core.ThreadStateMapping.getThreadState(ThreadStateMapping.java:32) >> at org.python.core.Py.getThreadState(Py.java:1457) >> at org.python.core.Py.getThreadState(Py.java:1453) >> at org.python.core.Py.getSystemState(Py.java:1473) >> >> at org.meteoinfo.laboratory.gui.ConsoleDockable.initializeConsole(ConsoleDockable.java:65) >> >> at org.meteoinfo.laboratory.gui.ConsoleDockable.<init>(ConsoleDockable.java:47) >> at org.meteoinfo.laboratory.gui.FrmMain.<init>(FrmMain.java:143) >> at org.meteoinfo.laboratory.MeteoInfoLab$1.run(MeteoInfoLab.java:264) >> >> Regards >> Yaqiang >> ------------------------------ >> ************************************************* >> Dr. Yaqiang Wang >> Chinese Academy of Meteorological Sciences (CAMS) >> 46, Zhong-Guan-Cun South Avenue >> Beijing, 100081 >> China >> >> yaq...@gm... >> >> http://www.meteothinker.com >> *https://www.researchgate.net/profile/Yaqiang_Wang5 >> <https://www.researchgate.net/profile/Yaqiang_Wang5>* >> ************************************************** >> >> >> *From:* Jim Baker <jim...@py...> >> *Date:* 2016-01-09 10:10 >> *To:* yaq...@gm... >> *CC:* jython-users <jyt...@li...> >> *Subject:* Re: [Jython-users] How to build Jython standalone jar from >> source code >> Yaqiang, >> >> Check out the source from https://hg.python.org/jython or the mirror at >> https://github.com/jythontools/jython >> >> You can build from source by using this ant target: >> >> all all-jars >> >> The standalone jar is in dist/jython-standalone.jar >> >> Please note that due to the use of an older version of Antlr, building is >> only currently supported on Java 7; but built jars will run on Java 7, 8, >> or 9. (Taking into account this limitation with Java 9: >> http://bugs.jython.org/issue2362) >> >> Hope this helps! >> >> - Jim >> >> On Fri, Jan 8, 2016 at 7:02 PM, yaq...@gm... < >> yaq...@gm...> wrote: >> >>> How to build Jython standalone jar from source code? Any help is >>> appreciated. >>> >>> Regrads >>> Yaqiang >>> ------------------------------ >>> ************************************************* >>> Dr. Yaqiang Wang >>> Chinese Academy of Meteorological Sciences (CAMS) >>> 46, Zhong-Guan-Cun South Avenue >>> Beijing, 100081 >>> China >>> >>> yaq...@gm... >>> >>> http://www.meteothinker.com >>> *https://www.researchgate.net/profile/Yaqiang_Wang5 >>> <https://www.researchgate.net/profile/Yaqiang_Wang5>* >>> ************************************************** >>> >>> >>> ------------------------------------------------------------------------------ >>> Site24x7 APM Insight: Get Deep Visibility into Application Performance >>> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month >>> Monitor end-to-end web transactions and take corrective actions now >>> Troubleshoot faster and improve end-user experience. Signup Now! >>> http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 >>> _______________________________________________ >>> Jython-users mailing list >>> Jyt...@li... >>> https://lists.sourceforge.net/lists/listinfo/jython-users >>> >>> >> > |