You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(107) |
Dec
(67) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(76) |
Feb
(125) |
Mar
(72) |
Apr
(13) |
May
(18) |
Jun
(12) |
Jul
(129) |
Aug
(47) |
Sep
(1) |
Oct
(36) |
Nov
(128) |
Dec
(124) |
2002 |
Jan
(59) |
Feb
|
Mar
(14) |
Apr
(14) |
May
(72) |
Jun
(9) |
Jul
(3) |
Aug
(5) |
Sep
(18) |
Oct
(65) |
Nov
(28) |
Dec
(12) |
2003 |
Jan
(10) |
Feb
(2) |
Mar
(4) |
Apr
(33) |
May
(21) |
Jun
(9) |
Jul
(29) |
Aug
(34) |
Sep
(4) |
Oct
(8) |
Nov
(15) |
Dec
(4) |
2004 |
Jan
(26) |
Feb
(12) |
Mar
(11) |
Apr
(9) |
May
(7) |
Jun
|
Jul
(5) |
Aug
|
Sep
(3) |
Oct
(7) |
Nov
(1) |
Dec
(10) |
2005 |
Jan
(2) |
Feb
(72) |
Mar
(16) |
Apr
(39) |
May
(48) |
Jun
(97) |
Jul
(57) |
Aug
(13) |
Sep
(16) |
Oct
(24) |
Nov
(100) |
Dec
(24) |
2006 |
Jan
(15) |
Feb
(34) |
Mar
(33) |
Apr
(31) |
May
(79) |
Jun
(64) |
Jul
(41) |
Aug
(64) |
Sep
(31) |
Oct
(46) |
Nov
(55) |
Dec
(37) |
2007 |
Jan
(32) |
Feb
(61) |
Mar
(11) |
Apr
(58) |
May
(46) |
Jun
(30) |
Jul
(94) |
Aug
(93) |
Sep
(86) |
Oct
(69) |
Nov
(125) |
Dec
(177) |
2008 |
Jan
(169) |
Feb
(97) |
Mar
(74) |
Apr
(113) |
May
(120) |
Jun
(334) |
Jul
(215) |
Aug
(237) |
Sep
(72) |
Oct
(189) |
Nov
(126) |
Dec
(160) |
2009 |
Jan
(180) |
Feb
(45) |
Mar
(98) |
Apr
(140) |
May
(151) |
Jun
(71) |
Jul
(107) |
Aug
(119) |
Sep
(73) |
Oct
(121) |
Nov
(14) |
Dec
(6) |
2010 |
Jan
(13) |
Feb
(9) |
Mar
(10) |
Apr
(64) |
May
(3) |
Jun
(16) |
Jul
(7) |
Aug
(23) |
Sep
(17) |
Oct
(37) |
Nov
(5) |
Dec
(8) |
2011 |
Jan
(10) |
Feb
(11) |
Mar
(77) |
Apr
(11) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Finn B. <bc...@us...> - 2000-11-20 21:57:52
|
Update of /cvsroot/jython/jython/org/python/core In directory slayer.i.sourceforge.net:/tmp/cvs-serv23572 Modified Files: imp.java Log Message: Removed the support for ModuleDictInit. It was a mistake. Index: imp.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/imp.java,v retrieving revision 2.30 retrieving revision 2.31 diff -C2 -r2.30 -r2.31 *** imp.java 2000/11/19 22:32:45 2.30 --- imp.java 2000/11/20 21:57:37 2.31 *************** *** 180,202 **** } } ! PyJavaClass ret = PyJavaClass.lookup(c); ! initModule(c, ret.__getattr__("__dict__")); ! return ret; } - public static void initModule(Class c, PyObject dict) { - if (ModuleDictInit.class.isAssignableFrom(c) - && c != ModuleDictInit.class) { - try { - Method m = c.getMethod("moduleDictInit", - new Class[] { PyObject.class }); - m.invoke(null, new Object[] { dict }); - } catch (Exception exc) { - // System.err.println("Got exception: " + exc + " " + proxyClass); - throw Py.JavaError(exc); - } - } - } - private static PyObject loadBuiltin(String name, PyList path) { if (name == "sys") --- 180,186 ---- } } ! return PyJavaClass.lookup(c); } private static PyObject loadBuiltin(String name, PyList path) { if (name == "sys") *************** *** 324,328 **** false); } - } return null; --- 308,311 ---- |
From: Finn B. <bc...@us...> - 2000-11-20 21:55:52
|
Update of /cvsroot/jython/jython/Tools/jythonc In directory slayer.i.sourceforge.net:/tmp/cvs-serv23196 Modified Files: PythonModule.py Log Message: Removed the support for ModuleDictInit. It was a mistake. Index: PythonModule.py =================================================================== RCS file: /cvsroot/jython/jython/Tools/jythonc/PythonModule.py,v retrieving revision 2.12 retrieving revision 2.13 diff -C2 -r2.12 -r2.13 *** PythonModule.py 2000/11/19 22:32:45 2.12 --- PythonModule.py 2000/11/20 21:55:49 2.13 *************** *** 405,409 **** supername = self.javaproxy.supername - self.interfaces += [org.python.core.ModuleDictInit] body = jast.Block(mycode) return jast.Class(self.name, self.modifier, supername, --- 405,408 ---- |
From: Samuele P. <ped...@us...> - 2000-11-19 22:32:48
|
Update of /cvsroot/jython/jython/org/python/core In directory slayer.i.sourceforge.net:/tmp/cvs-serv3159/org/python/core Modified Files: BytecodeLoader.java PyDictionary.java PyReflectedConstructor.java PySystemState.java imp.java Log Message: * [Bug #122610] SecEx in MS applerviewer, now if Py.frozen true: sys.path=[] cache not init. * BytecodeLoader now uses findLoadedClass to avoid redef exc. More robust jythonc/compile.getJavaClass. * mini-fix to enable compilation inside Sun Forte (tm). * makeup Index: BytecodeLoader.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/BytecodeLoader.java,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -r2.7 -r2.8 *** BytecodeLoader.java 2000/11/17 12:32:43 2.7 --- BytecodeLoader.java 2000/11/19 22:32:45 2.8 *************** *** 59,62 **** --- 59,66 ---- } + Class c = findLoadedClass(name); + if (c != null) + return c; + /* previously: if Options.extendedClassLoader && Index: PyDictionary.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyDictionary.java,v retrieving revision 2.9 retrieving revision 2.10 diff -C2 -r2.9 -r2.10 *** PyDictionary.java 2000/09/29 17:46:20 2.9 --- PyDictionary.java 2000/11/19 22:32:45 2.10 *************** *** 75,80 **** ! public class PyDictionary extends PyObject implements InitModule { protected Hashtable table; protected static PyObject __methods__; --- 75,81 ---- ! public class PyDictionary extends PyObject implements ClassDictInit { + protected Hashtable table; protected static PyObject __methods__; *************** *** 106,110 **** } ! public void initModule(PyObject dict) { dict.__setitem__("__len__", new DictFuncs("__len__", 1, 0)); dict.__setitem__("__nonzero__", new DictFuncs("__nonzero__", 2, 0)); --- 107,111 ---- } ! public static void classDictInit(PyObject dict) { dict.__setitem__("__len__", new DictFuncs("__len__", 1, 0)); dict.__setitem__("__nonzero__", new DictFuncs("__nonzero__", 2, 0)); *************** *** 124,127 **** --- 125,129 ---- dict.__setitem__("toString", null); dict.__setitem__("hashCode", null); + dict.__setitem__("classDictInit", null); } Index: PyReflectedConstructor.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyReflectedConstructor.java,v retrieving revision 2.5 retrieving revision 2.6 diff -C2 -r2.5 -r2.6 *** PyReflectedConstructor.java 1999/09/16 22:05:38 2.5 --- PyReflectedConstructor.java 2000/11/19 22:32:45 2.6 *************** *** 117,121 **** // Do the actual constructor call ! Object jself; ThreadState ts = Py.getThreadState(); try { --- 117,121 ---- // Do the actual constructor call ! Object jself = null; ThreadState ts = Py.getThreadState(); try { Index: PySystemState.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PySystemState.java,v retrieving revision 2.31 retrieving revision 2.32 diff -C2 -r2.31 -r2.32 *** PySystemState.java 2000/11/17 20:52:48 2.31 --- PySystemState.java 2000/11/19 22:32:45 2.32 *************** *** 309,316 **** // Initialize the path (and add system defaults) defaultPath = initPath(registry); - if (prefix != null) { - String libpath = new File(prefix, "Lib").toString(); - defaultPath.append(new PyString(libpath)); - } // Set up the known Java packages --- 309,312 ---- *************** *** 435,444 **** private static PyList initPath(Properties props) { PyList path = new PyList(); ! String pypath = props.getProperty("python.path", ""); ! StringTokenizer tok = new StringTokenizer(pypath, java.io.File.pathSeparator); ! while (tok.hasMoreTokens()) { ! String p = tok.nextToken(); ! path.append(new PyString(p.trim())); } return path; --- 431,446 ---- private static PyList initPath(Properties props) { PyList path = new PyList(); ! if (!Py.frozen) { ! String pypath = props.getProperty("python.path", ""); ! StringTokenizer tok = new StringTokenizer(pypath, java.io.File.pathSeparator); ! while (tok.hasMoreTokens()) { ! String p = tok.nextToken(); ! path.append(new PyString(p.trim())); ! } ! if (prefix != null) { ! String libpath = new File(prefix, "Lib").toString(); ! path.append(new PyString(libpath)); ! } } return path; Index: imp.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/imp.java,v retrieving revision 2.29 retrieving revision 2.30 diff -C2 -r2.29 -r2.30 *** imp.java 2000/11/17 21:14:24 2.29 --- imp.java 2000/11/19 22:32:45 2.30 *************** *** 162,170 **** } - private static PyObject createFromClass(String name, InputStream fp) { - BytecodeLoader bcl = getSyspathJavaLoader(); - return createFromClass(name, bcl.makeClass(name, readBytes(fp))); - } - private static PyObject createFromClass(String name, Class c) { //Two choices. c implements PyRunnable or c is Java package --- 162,165 ---- |
From: Samuele P. <ped...@us...> - 2000-11-19 22:32:48
|
Update of /cvsroot/jython/jython/Tools/jythonc In directory slayer.i.sourceforge.net:/tmp/cvs-serv3159/Tools/jythonc Modified Files: PythonModule.py compile.py Log Message: * [Bug #122610] SecEx in MS applerviewer, now if Py.frozen true: sys.path=[] cache not init. * BytecodeLoader now uses findLoadedClass to avoid redef exc. More robust jythonc/compile.getJavaClass. * mini-fix to enable compilation inside Sun Forte (tm). * makeup Index: PythonModule.py =================================================================== RCS file: /cvsroot/jython/jython/Tools/jythonc/PythonModule.py,v retrieving revision 2.11 retrieving revision 2.12 diff -C2 -r2.11 -r2.12 *** PythonModule.py 2000/11/17 21:18:22 2.11 --- PythonModule.py 2000/11/19 22:32:45 2.12 *************** *** 212,217 **** defaultProps = { ! "python.packages.paths": "", ! "python.packages.directories": "", "python.options.showJavaExceptions": "true", "python.modules.builtin": "exceptions:org.python.core.exceptions", --- 212,218 ---- defaultProps = { ! ## now redundant ! ## "python.packages.paths": "", ! ## "python.packages.directories": "", "python.options.showJavaExceptions": "true", "python.modules.builtin": "exceptions:org.python.core.exceptions", Index: compile.py =================================================================== RCS file: /cvsroot/jython/jython/Tools/jythonc/compile.py,v retrieving revision 2.13 retrieving revision 2.14 diff -C2 -r2.13 -r2.14 *** compile.py 2000/11/17 12:44:21 2.13 --- compile.py 2000/11/19 22:32:45 2.14 *************** *** 115,119 **** if c.endswith("[]"): # java1.1 allows only this ! return Class.getClass(reflect.Array.newInstance(getJavaClass(c[:-2]),0)) try: return util.findClass(c) #Class.forName(c) --- 115,122 ---- if c.endswith("[]"): # java1.1 allows only this ! el = getJavaClass(c[:-2]) ! if el == None: ! return None ! return Class.getClass(reflect.Array.newInstance(el,0)) try: return util.findClass(c) #Class.forName(c) |
From: Finn B. <bc...@us...> - 2000-11-17 21:28:22
|
Update of /cvsroot/jython/jython/org/python/parser In directory slayer.i.sourceforge.net:/tmp/cvs-serv16827 Modified Files: SimpleNode.java Log Message: Only interpret \uXXXX sequences in u"" strings. This improves CPython compatibility. Index: SimpleNode.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/parser/SimpleNode.java,v retrieving revision 2.10 retrieving revision 2.11 diff -C2 -r2.10 -r2.11 *** SimpleNode.java 2000/10/20 09:10:39 2.10 --- SimpleNode.java 2000/11/17 21:28:06 2.11 *************** *** 83,88 **** char quoteChar = s.charAt(0); int start=0; ! if (quoteChar == 'u' || quoteChar == 'U') ! start++; quoteChar = s.charAt(start); if (quoteChar == 'r' || quoteChar == 'R') { --- 83,91 ---- char quoteChar = s.charAt(0); int start=0; ! boolean ustring = false; ! if (quoteChar == 'u' || quoteChar == 'U') { ! ustring = true; ! start++; ! } quoteChar = s.charAt(start); if (quoteChar == 'r' || quoteChar == 'R') { *************** *** 142,145 **** --- 145,152 ---- break; case 'u': + if (!ustring) { + sb.append('u'); + break; + } if (i+4 > n) throw new TokenMgrError( |
From: Finn B. <bc...@us...> - 2000-11-17 21:23:47
|
Update of /cvsroot/jython/jython/org/python/core In directory slayer.i.sourceforge.net:/tmp/cvs-serv16280 Modified Files: Py.java Log Message: Do not assume that a PyJavaClass is initialized. Instead call __getattr__ which will perform the initialization if needed. Index: Py.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/Py.java,v retrieving revision 2.25 retrieving revision 2.26 diff -C2 -r2.25 -r2.26 *** Py.java 2000/11/17 12:32:43 2.25 --- Py.java 2000/11/17 21:23:42 2.26 *************** *** 376,380 **** public static void setBuiltinExceptions() { PyObject dict = PyJavaClass.lookup( ! org.python.core.__builtin__.class).__dict__; dict.__setitem__("Exception", Py.Exception); dict.__setitem__("TypeError", Py.TypeError); --- 376,380 ---- public static void setBuiltinExceptions() { PyObject dict = PyJavaClass.lookup( ! org.python.core.__builtin__.class).__getattr__("__dict__"); dict.__setitem__("Exception", Py.Exception); dict.__setitem__("TypeError", Py.TypeError); |
From: Finn B. <bc...@us...> - 2000-11-17 21:22:19
|
Update of /cvsroot/jython/jython/org/python/core In directory slayer.i.sourceforge.net:/tmp/cvs-serv15971 Modified Files: PyJavaClass.java Log Message: Delay ClassDictInit until the time the class is fully initialized. This fix a situation in applets in IE where the org.python.core classes depends on the initialization sequence of each other. Index: PyJavaClass.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyJavaClass.java,v retrieving revision 2.24 retrieving revision 2.25 diff -C2 -r2.24 -r2.25 *** PyJavaClass.java 2000/11/17 12:32:43 2.24 --- PyJavaClass.java 2000/11/17 21:22:15 2.25 *************** *** 79,82 **** --- 79,95 ---- init__bases__(proxyClass); init__dict__(); + + if (ClassDictInit.class.isAssignableFrom(proxyClass) + && proxyClass != ClassDictInit.class) { + try { + Method m = proxyClass.getMethod("classDictInit", + new Class[] { PyObject.class }); + m.invoke(null, new Object[] { __dict__ }); + } + catch (Exception exc) { + // System.err.println("Got exception: " + exc + " " + proxyClass); + throw Py.JavaError(exc); + } + } initialized = true; initializing = false; *************** *** 172,188 **** __name__ = c.getName(); ! if (ClassDictInit.class.isAssignableFrom(c) ! && c != ClassDictInit.class) { ! initialize(); ! try { ! Method m = c.getMethod("classDictInit", ! new Class[] { PyObject.class }); ! m.invoke(null, new Object[] { __dict__ }); ! } ! catch (Exception exc) { ! // System.err.println("Got exception: " + exc + " " + c); ! throw Py.JavaError(exc); ! } ! } else if (InitModule.class.isAssignableFrom(c)) { initialize(); try { --- 185,189 ---- __name__ = c.getName(); ! if (InitModule.class.isAssignableFrom(c)) { initialize(); try { *************** *** 681,685 **** if (name == "__dict__") { if (__dict__ == null) ! init__dict__(); return __dict__; } --- 682,686 ---- if (name == "__dict__") { if (__dict__ == null) ! initialize(); return __dict__; } |
From: Finn B. <bc...@us...> - 2000-11-17 21:18:27
|
Update of /cvsroot/jython/jython/Tools/jythonc In directory slayer.i.sourceforge.net:/tmp/cvs-serv15595 Modified Files: PythonModule.py Log Message: Compiled modules will implement ModuleDictInit. This allow module initialization when the module is imported. And it avoid a second module initialization when the proxyclass is initialized. Index: PythonModule.py =================================================================== RCS file: /cvsroot/jython/jython/Tools/jythonc/PythonModule.py,v retrieving revision 2.10 retrieving revision 2.11 diff -C2 -r2.10 -r2.11 *** PythonModule.py 2000/10/28 19:17:36 2.10 --- PythonModule.py 2000/11/17 21:18:22 2.11 *************** *** 344,348 **** [jast.Invoke(dict, "__setitem__", sargs), jast.InvokeStatic("Py", "runCode", rargs)]) ! meths.append(jast.Method("classDictInit", "public static", ["void", ("PyObject", "dict")], code)) return meths --- 344,348 ---- [jast.Invoke(dict, "__setitem__", sargs), jast.InvokeStatic("Py", "runCode", rargs)]) ! meths.append(jast.Method("moduleDictInit", "public static", ["void", ("PyObject", "dict")], code)) return meths *************** *** 404,408 **** supername = self.javaproxy.supername ! self.interfaces += [org.python.core.ClassDictInit] body = jast.Block(mycode) return jast.Class(self.name, self.modifier, supername, --- 404,408 ---- supername = self.javaproxy.supername ! self.interfaces += [org.python.core.ModuleDictInit] body = jast.Block(mycode) return jast.Class(self.name, self.modifier, supername, |
From: Finn B. <bc...@us...> - 2000-11-17 21:14:27
|
Update of /cvsroot/jython/jython/org/python/core In directory slayer.i.sourceforge.net:/tmp/cvs-serv15269 Modified Files: imp.java Log Message: Support initialization of java classes which implement the ModuleDictInit initerface. Index: imp.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/imp.java,v retrieving revision 2.28 retrieving revision 2.29 diff -C2 -r2.28 -r2.29 *** imp.java 2000/11/17 21:12:40 2.28 --- imp.java 2000/11/17 21:14:24 2.29 *************** *** 2,5 **** --- 2,6 ---- package org.python.core; + import java.lang.reflect.*; import java.io.*; import java.util.Hashtable; *************** *** 184,188 **** } } ! return PyJavaClass.lookup(c); } --- 185,205 ---- } } ! PyJavaClass ret = PyJavaClass.lookup(c); ! initModule(c, ret.__getattr__("__dict__")); ! return ret; ! } ! ! public static void initModule(Class c, PyObject dict) { ! if (ModuleDictInit.class.isAssignableFrom(c) ! && c != ModuleDictInit.class) { ! try { ! Method m = c.getMethod("moduleDictInit", ! new Class[] { PyObject.class }); ! m.invoke(null, new Object[] { dict }); ! } catch (Exception exc) { ! // System.err.println("Got exception: " + exc + " " + proxyClass); ! throw Py.JavaError(exc); ! } ! } } |
From: Finn B. <bc...@us...> - 2000-11-17 21:12:59
|
Update of /cvsroot/jython/jython/org/python/core In directory slayer.i.sourceforge.net:/tmp/cvs-serv15045 Modified Files: imp.java Log Message: Avoid static initializers in this file. For some unknown reason they break applets in MS-IE. Index: imp.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/imp.java,v retrieving revision 2.27 retrieving revision 2.28 diff -C2 -r2.27 -r2.28 *** imp.java 2000/11/17 12:32:43 2.27 --- imp.java 2000/11/17 21:12:40 2.28 *************** *** 526,530 **** frame.f_globals, frame.f_locals, ! all }); --- 526,530 ---- frame.f_globals, frame.f_locals, ! getStarArg() }); *************** *** 570,578 **** } ! private static PyTuple all = new PyTuple( ! new PyString[] { ! Py.newString('*') ! }); /** * Called from jpython generated code when a statement like --- 570,581 ---- } ! private static PyTuple all = null; + private synchronized static PyTuple getStarArg() { + if (all == null) + all = new PyTuple(new PyString[] { Py.newString('*') }); + return all; + } + /** * Called from jpython generated code when a statement like *************** *** 585,589 **** frame.f_globals, frame.f_locals, ! all } ); PyObject names; if (module instanceof PyJavaPackage) names = ((PyJavaPackage)module).fillDir(); --- 588,592 ---- frame.f_globals, frame.f_locals, ! getStarArg() } ); PyObject names; if (module instanceof PyJavaPackage) names = ((PyJavaPackage)module).fillDir(); *************** *** 655,661 **** } ! private static PyObject __import__ = Py.newString("__import__"); private static PyObject getImportFunc(PyFrame frame) { // Set up f_builtins if not already set PyObject builtins = frame.f_builtins; --- 658,666 ---- } ! private static PyObject __import__ = null; private static PyObject getImportFunc(PyFrame frame) { + if (__import__ == null) + __import__ = Py.newString("__import__"); // Set up f_builtins if not already set PyObject builtins = frame.f_builtins; |
From: Finn B. <bc...@us...> - 2000-11-17 20:54:13
|
Update of /cvsroot/jython/jython/org/python/core In directory slayer.i.sourceforge.net:/tmp/cvs-serv12920 Added Files: ModuleDictInit.java Log Message: First version. --- NEW FILE --- // Copyright 2000 Finn Bock package org.python.core; /** * An empty tagging interface. If a java class implements this * interface, it must also have a method like: * <pre> * public static void moduleDictInit(PyObject dict) { .. } * </pre> * The method will be called when the class is imported. The * method can then make changes to the class's __dict__ instance, * f.example be removing method that should not be avaiable in python * or by replacing some method with high performance versions. */ public interface ModuleDictInit { // An empty tagging interface. } |
From: Finn B. <bc...@us...> - 2000-11-17 20:52:51
|
Update of /cvsroot/jython/jython/org/python/core In directory slayer.i.sourceforge.net:/tmp/cvs-serv12723 Modified Files: PySystemState.java Log Message: Changed name of the support files: jython.jar and .jython Index: PySystemState.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PySystemState.java,v retrieving revision 2.30 retrieving revision 2.31 diff -C2 -r2.30 -r2.31 *** PySystemState.java 2000/11/17 12:32:43 2.30 --- PySystemState.java 2000/11/17 20:52:48 2.31 *************** *** 209,213 **** return null; ! int jpy = classpath.toLowerCase().indexOf("jpython.jar"); if (jpy == -1) { return null; --- 209,213 ---- return null; ! int jpy = classpath.toLowerCase().indexOf("jython.jar"); if (jpy == -1) { return null; *************** *** 233,237 **** addRegistryFile(new File(prefix, "registry")); File homeFile = new File(registry.getProperty("user.home"), ! ".jpython"); addRegistryFile(homeFile); } catch (Exception exc) { --- 233,237 ---- addRegistryFile(new File(prefix, "registry")); File homeFile = new File(registry.getProperty("user.home"), ! ".jython"); addRegistryFile(homeFile); } catch (Exception exc) { |
From: Finn B. <bc...@us...> - 2000-11-17 20:49:11
|
Update of /cvsroot/jython/jython/Tools/jythonc In directory slayer.i.sourceforge.net:/tmp/cvs-serv12100 Modified Files: ObjectFactory.py Log Message: Fixed a bug where the superclass proxy was in another module, but where is was not the main proxy. Index: ObjectFactory.py =================================================================== RCS file: /cvsroot/jython/jython/Tools/jythonc/ObjectFactory.py,v retrieving revision 2.5 retrieving revision 2.6 diff -C2 -r2.5 -r2.6 *** ObjectFactory.py 2000/11/10 15:08:48 2.5 --- ObjectFactory.py 2000/11/17 20:49:00 2.6 *************** *** 227,230 **** --- 227,232 ---- self.proxyname = self.name self.supername = cls.value.name + if cls.value.name != mod.name: + self.supername = mod.name + '.' + self.supername continue |
From: Finn B. <bc...@us...> - 2000-11-17 20:46:21
|
Update of /cvsroot/jython/jython/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv11911 Modified Files: getopt.py Log Message: getopt.py from CPython-2.0. Index: getopt.py =================================================================== RCS file: /cvsroot/jython/jython/Lib/getopt.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** getopt.py 1999/06/08 20:10:03 1.1 --- getopt.py 2000/11/17 20:46:17 1.2 *************** *** 1,3 **** ! """Module getopt -- Parser for command line options. This module helps scripts to parse the command line arguments in --- 1,3 ---- ! """Parser for command line options. This module helps scripts to parse the command line arguments in *************** *** 9,21 **** getopt() -- Parse command line options ! error -- Exception (string) raised when bad options are found """ # Long option support added by Lars Wirzenius <li...@ik...>. ! import string ! error = 'getopt.error' def getopt(args, shortopts, longopts = []): """getopt(args, options[, long_options]) -> opts, args --- 9,37 ---- getopt() -- Parse command line options ! GetoptError -- exception (class) raised with 'opt' attribute, which is the ! option involved with the exception. """ # Long option support added by Lars Wirzenius <li...@ik...>. ! # Gerrit Holl <ge...@nl...> moved the string-based exceptions ! # to class-based exceptions. ! class GetoptError(Exception): ! opt = '' ! msg = '' ! def __init__(self, *args): ! self.args = args ! if len(args) == 1: ! self.msg = args[0] ! elif len(args) == 2: ! self.msg = args[0] ! self.opt = args[1] + def __str__(self): + return self.msg + + error = GetoptError # backward compatibility + def getopt(args, shortopts, longopts = []): """getopt(args, options[, long_options]) -> opts, args *************** *** 64,68 **** def do_longs(opts, opt, longopts, args): try: ! i = string.index(opt, '=') opt, optarg = opt[:i], opt[i+1:] except ValueError: --- 80,84 ---- def do_longs(opts, opt, longopts, args): try: ! i = opt.index('=') opt, optarg = opt[:i], opt[i+1:] except ValueError: *************** *** 73,80 **** if optarg is None: if not args: ! raise error, 'option --%s requires argument' % opt optarg, args = args[0], args[1:] elif optarg: ! raise error, 'option --%s must not have an argument' % opt opts.append(('--' + opt, optarg or '')) return opts, args --- 89,96 ---- if optarg is None: if not args: ! raise GetoptError('option --%s requires argument' % opt, opt) optarg, args = args[0], args[1:] elif optarg: ! raise GetoptError('option --%s must not have an argument' % opt, opt) opts.append(('--' + opt, optarg or '')) return opts, args *************** *** 91,99 **** if y != '' and y != '=' and i+1 < len(longopts): if opt == longopts[i+1][:optlen]: ! raise error, 'option --%s not a unique prefix' % opt if longopts[i][-1:] in ('=', ): return 1, longopts[i][:-1] return 0, longopts[i] ! raise error, 'option --' + opt + ' not recognized' def do_shorts(opts, optstring, shortopts, args): --- 107,115 ---- if y != '' and y != '=' and i+1 < len(longopts): if opt == longopts[i+1][:optlen]: ! raise GetoptError('option --%s not a unique prefix' % opt, opt) if longopts[i][-1:] in ('=', ): return 1, longopts[i][:-1] return 0, longopts[i] ! raise GetoptError('option --%s not recognized' % opt, opt) def do_shorts(opts, optstring, shortopts, args): *************** *** 103,107 **** if optstring == '': if not args: ! raise error, 'option -%s requires argument' % opt optstring, args = args[0], args[1:] optarg, optstring = optstring, '' --- 119,123 ---- if optstring == '': if not args: ! raise GetoptError('option -%s requires argument' % opt, opt) optstring, args = args[0], args[1:] optarg, optstring = optstring, '' *************** *** 115,119 **** if opt == shortopts[i] != ':': return shortopts[i+1:i+2] == ':' ! raise error, 'option -%s not recognized' % opt if __name__ == '__main__': --- 131,135 ---- if opt == shortopts[i] != ':': return shortopts[i+1:i+2] == ':' ! raise GetoptError('option -%s not recognized' % opt, opt) if __name__ == '__main__': |
From: Finn B. <bc...@us...> - 2000-11-17 14:14:22
|
Update of /cvsroot/jython/jython/Doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv15716 Modified Files: compile.html differences.html embedding.html faq.html index.html interpreter.html jarray.html jythonc.html properties.html registry.html subclassing.html usejava.html whatis.html Log Message: Generated .html files. Index: compile.html =================================================================== RCS file: /cvsroot/jython/jython/Doc/compile.html,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** compile.html 1999/09/22 20:33:16 1.5 --- compile.html 2000/11/17 14:14:17 1.6 *************** *** 1,14 **** <HTML> <!-- THIS PAGE IS AUTOMATICALLY GENERATED. DO NOT EDIT. --> ! <!-- Wed Sep 22 16:32:59 1999 --> ! <!-- USING HT2HTML 1.0 --> <!-- SEE http://www.python.org/~bwarsaw/software/pyware.html --> <!-- User-specified headers: ! Title: Compiling JPython --> <HEAD> ! <TITLE>Compiling JPython</TITLE> </HEAD> --- 1,14 ---- <HTML> <!-- THIS PAGE IS AUTOMATICALLY GENERATED. DO NOT EDIT. --> ! <!-- Fri Nov 17 14:50:48 2000 --> ! <!-- USING HT2HTML 1.1 --> <!-- SEE http://www.python.org/~bwarsaw/software/pyware.html --> <!-- User-specified headers: ! Title: Compiling Jython --> <HEAD> ! <TITLE>Compiling Jython</TITLE> </HEAD> *************** *** 25,30 **** <center> ! <a href="http://www.jpython.org/"> ! <img border=0 src="./images/jpython-new-small.gif"></a></center> </TD> <TD WIDTH=15 BGCOLOR="#cdb7b5"> </TD><!--spacer--> <!-- end of corner cells --> --- 25,30 ---- <center> ! <a href="http://jython.sourceforge.net/"> ! <img border=0 src="./images/jython-new-small.gif"></a></center> </TD> <TD WIDTH=15 BGCOLOR="#cdb7b5"> </TD><!--spacer--> <!-- end of corner cells --> *************** *** 37,41 **** <TR> <TD BGCOLOR="#cdb7b5"> ! <a href="http://www.jpython.org/">Home</a> </TD> <TD BGCOLOR="#cdb7b5"> --- 37,41 ---- <TR> <TD BGCOLOR="#cdb7b5"> ! <a href="http://jython.sourceforge.net/">Home</a> </TD> <TD BGCOLOR="#cdb7b5"> *************** *** 44,48 **** </TR><TR> <TD BGCOLOR="#cdb7b5"> ! <a href="http://www.jpython.org/download.html">Download</a> </TD> <TD BGCOLOR="#cdb7b5"> --- 44,48 ---- </TR><TR> <TD BGCOLOR="#cdb7b5"> ! <a href="http://jython.sourceforge.net/download.html">Download</a> </TD> <TD BGCOLOR="#cdb7b5"> *************** *** 70,77 **** </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="interpreter.html">Invoking JPython</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="registry.html">JPython Registry</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> --- 70,77 ---- </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="interpreter.html">Invoking Jython</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="registry.html">Jython Registry</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> *************** *** 79,83 **** </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <b>Compiling JPython from source</b> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> --- 79,83 ---- </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <b>Compiling Jython from source</b> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> *************** *** 98,102 **** </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="jpythonc.html">Building applets, servlets, beans...</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> --- 98,102 ---- </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="jythonc.html">Building applets, servlets, beans...</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> *************** *** 115,125 **** </FONT></B></TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="differences.html">JPython vs. CPython</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="faq.html">JPython FAQ</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="http://www.python.org/pipermail/jpython-interest/">List Archives</A> (exit) </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> --- 115,125 ---- </FONT></B></TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="differences.html">Jython vs. CPython</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="faq.html">Jython FAQ</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="http://www.geocrawler.com/archives/3/7017/2000/">List Archives</A> (exit) </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> *************** *** 131,135 **** </FONT></B></TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="mailto:jp...@py...">jp...@py...</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> --- 131,135 ---- </FONT></B></TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="mailto:jyt...@li...">jyt...@li...</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> *************** *** 142,145 **** --- 142,148 ---- </A> </TD></TR> + <TR><TD BGCOLOR="#cdb7b5"> + + </TD></TR> </TABLE><!-- end of sidebar table --> *************** *** 149,198 **** <!-- start of body cell --> <TD VALIGN=TOP WIDTH="90%"><BR> ! <h3>Compiling JPython</h3> ! <P>Most users of JPython will never be required to look at the ! contents of the src directory, or try and recompile any of the files in the org.python package. All of these files have been precompiled in ! jpython.jar.</P> ! <P>For those people who do want to rebuild JPython from the source, for whatever reason, the following offers a few tips to keep in mind.</P> ! <P>The source to many of the classes in the org.python.parser package ! are not distributed with JPython. These classes are produced from the ! file "python.jjt" using the ! <A HREF="http://www.metamata.com/javacc/">JavaCC</A> parser generator ! tool. When rebuilding JPython from source you have two options for ! generating these classes: ! ! <OL> ! <LI>Copy all of the .class files from jpython.jar into src. Then ! only rebuild those files in packages other than ! org.python.parser. This is the recommended choice unless you ! explicitly want to experiment with the JPython ! grammar/parser. ! ! <LI>Get <A HREF="http://www.metamata.com/javacc/">JavaCC</A> ! <sup>1</sup>. ! Run jjtree on python.jjt, and then run javacc on the resulting ! python.jj. This should produce all of the required source ! files to build the org.python.parser package. ! </OL> ! ! <P></P> ! ! <P>The file in src/installer/MakeScriptAction.java is only used by the ! JPython installer. You should have no need to recompile this file ! unless you plan to build a new installer for JPython. This file ! depends on packages from ! <A HREF="http://www.installshield.com/java">InstallShield Java ! Edition</A>, and you must have this software installed and in your ! CLASSPATH before you can rebuild this file. <hr> ! <sup>1</sup>JavaCC version 0.7.1 is required. Specifically, newer ! versions of JavaCC are known to be incompatible with JPython's grammar ! file. This will be fixed in a later release. </TD><!-- end of body cell --> --- 152,188 ---- <!-- start of body cell --> <TD VALIGN=TOP WIDTH="90%"><BR> ! <h3>Compiling Jython</h3> ! <P>Most users of Jython will never be required to look at the ! contents of the source directories, or try and recompile any of the files in the org.python package. All of these files have been precompiled in ! jython.jar.</P> ! <P>For those people who do want to rebuild Jython from the source, for whatever reason, the following offers a few tips to keep in mind.</P> + + <P>Some of the sources in the org.python.parser package are generated + from python.jtt file by the JavaCC parser generator. If you need to + make changes to the grammar file you will need to download this + <A HREF="http://www.metamata.com/javacc/">JavaCC</A> too. The generated + files are also in the distribution, so usually this is not necessary. + + <P>To regenerate the parser from the grammar, run jjtree on python.jjt, + and then run javacc on the resulting python.jj. This should produce all + of the required source files to build the org.python.parser package. + + <P>If you have further interest in the Jython source and Jython's + continued development, you can read the archives for the + <a href="http://www.geocrawler.com/lists/3/SourceForge/7018/0/"> + Jython-dev mailing list</a> or you can + <a href="http://lists.sourceforge.net/mailman/listinfo/jython-dev">join</a> + the list. ! <P> <hr> ! <sup>1</sup>JavaCC version 2.0 is used to create the generated sources ! included with the distribution. </TD><!-- end of body cell --> Index: differences.html =================================================================== RCS file: /cvsroot/jython/jython/Doc/differences.html,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** differences.html 2000/01/22 01:09:35 1.10 --- differences.html 2000/11/17 14:14:17 1.11 *************** *** 1,14 **** <HTML> <!-- THIS PAGE IS AUTOMATICALLY GENERATED. DO NOT EDIT. --> ! <!-- Fri Jan 21 20:05:33 2000 --> <!-- USING HT2HTML 1.1 --> <!-- SEE http://www.python.org/~bwarsaw/software/pyware.html --> <!-- User-specified headers: ! Title: Differences between CPython and JPython --> <HEAD> ! <TITLE>Differences between CPython and JPython</TITLE> </HEAD> --- 1,14 ---- <HTML> <!-- THIS PAGE IS AUTOMATICALLY GENERATED. DO NOT EDIT. --> ! <!-- Fri Nov 17 14:50:48 2000 --> <!-- USING HT2HTML 1.1 --> <!-- SEE http://www.python.org/~bwarsaw/software/pyware.html --> <!-- User-specified headers: ! Title: Differences between CPython and Jython --> <HEAD> ! <TITLE>Differences between CPython and Jython</TITLE> </HEAD> *************** *** 25,30 **** <center> ! <a href="http://www.jpython.org/"> ! <img border=0 src="./images/jpython-new-small.gif"></a></center> </TD> <TD WIDTH=15 BGCOLOR="#cdb7b5"> </TD><!--spacer--> <!-- end of corner cells --> --- 25,30 ---- <center> ! <a href="http://jython.sourceforge.net/"> ! <img border=0 src="./images/jython-new-small.gif"></a></center> </TD> <TD WIDTH=15 BGCOLOR="#cdb7b5"> </TD><!--spacer--> <!-- end of corner cells --> *************** *** 37,41 **** <TR> <TD BGCOLOR="#cdb7b5"> ! <a href="http://www.jpython.org/">Home</a> </TD> <TD BGCOLOR="#cdb7b5"> --- 37,41 ---- <TR> <TD BGCOLOR="#cdb7b5"> ! <a href="http://jython.sourceforge.net/">Home</a> </TD> <TD BGCOLOR="#cdb7b5"> *************** *** 44,48 **** </TR><TR> <TD BGCOLOR="#cdb7b5"> ! <a href="http://www.jpython.org/download.html">Download</a> </TD> <TD BGCOLOR="#cdb7b5"> --- 44,48 ---- </TR><TR> <TD BGCOLOR="#cdb7b5"> ! <a href="http://jython.sourceforge.net/download.html">Download</a> </TD> <TD BGCOLOR="#cdb7b5"> *************** *** 70,77 **** </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="interpreter.html">Invoking JPython</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="registry.html">JPython Registry</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> --- 70,77 ---- </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="interpreter.html">Invoking Jython</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="registry.html">Jython Registry</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> *************** *** 79,83 **** </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="compile.html">Compiling JPython from source</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> --- 79,83 ---- </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="compile.html">Compiling Jython from source</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> *************** *** 98,102 **** </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="jpythonc.html">Building applets, servlets, beans...</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> --- 98,102 ---- </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="jythonc.html">Building applets, servlets, beans...</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> *************** *** 115,125 **** </FONT></B></TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <b>JPython vs. CPython</b> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="faq.html">JPython FAQ</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="http://www.python.org/pipermail/jpython-interest/">List Archives</A> (exit) </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> --- 115,125 ---- </FONT></B></TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <b>Jython vs. CPython</b> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="faq.html">Jython FAQ</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="http://www.geocrawler.com/archives/3/7017/2000/">List Archives</A> (exit) </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> *************** *** 131,135 **** </FONT></B></TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="mailto:jp...@py...">jp...@py...</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> --- 131,135 ---- </FONT></B></TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="mailto:jyt...@li...">jyt...@li...</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> *************** *** 142,145 **** --- 142,148 ---- </A> </TD></TR> + <TR><TD BGCOLOR="#cdb7b5"> + + </TD></TR> </TABLE><!-- end of sidebar table --> *************** *** 149,155 **** <!-- start of body cell --> <TD VALIGN=TOP WIDTH="90%"><BR> ! <h3>Differences between CPython and JPython</h3> ! <P>CPython and JPython are two different implementations of the Python language. While a <A HREF="http://www.python.org/doc/ref">Language Reference</A> exists for the Python language, there are a number of --- 152,158 ---- <!-- start of body cell --> <TD VALIGN=TOP WIDTH="90%"><BR> ! <h3>Differences between CPython and Jython</h3> ! <P>CPython and Jython are two different implementations of the Python language. While a <A HREF="http://www.python.org/doc/ref">Language Reference</A> exists for the Python language, there are a number of *************** *** 157,182 **** following lists all known differences between the two implementations of the Python language. These differences range from the trivial -- ! JPython prints "1.0E20" where CPython prints ! "1e+020" -- to the dramatic -- everything in JPython is an instance of a class. At some point more effort should be made to separate the interesting differences from the mundane. <p>Any other differences not listed here can probably be considered a ! bug in JPython. Understand of course that CPython and JPython advance at different paces. All efforts are made to keep the two implementations in sync, but that's not always possible. <p><i>This list ! has been updated to describe the differences between JPython 1.1beta4 and ! CPython 1.5.2</i> <h3>Syntax</h3> <UL> ! <LI>JPython has a different interpretation of floating point literals. CPython doesn't allow 001.1 <I>CPython should be fixed.</I> ! <p><LI>JPython supports continue in a try clause. <I>CPython should be fixed - but don't hold your breath.</I> </UL> --- 160,185 ---- following lists all known differences between the two implementations of the Python language. These differences range from the trivial -- ! Jython prints "1.0E20" where CPython prints ! "1e+020" -- to the dramatic -- everything in Jython is an instance of a class. At some point more effort should be made to separate the interesting differences from the mundane. <p>Any other differences not listed here can probably be considered a ! bug in Jython. Understand of course that CPython and Jython advance at different paces. All efforts are made to keep the two implementations in sync, but that's not always possible. <p><i>This list ! has been updated to describe the differences between Jython-2.0 and ! CPython 2.0</i> <h3>Syntax</h3> <UL> ! <LI>Jython has a different interpretation of floating point literals. CPython doesn't allow 001.1 <I>CPython should be fixed.</I> ! <p><LI>Jython supports continue in a try clause. <I>CPython should be fixed - but don't hold your breath.</I> </UL> *************** *** 185,237 **** <UL> ! <LI>JPython string objects support full two-byte Unicode ! characters and the functions in the string module are ! Unicode-aware. <I>CPython should add Unicode support in the ! future, though the details of this are still unclear.</I> ! ! <p><li>JPython string objects have methods, providing a more ! convenient interface to most of the string module functionality. ! <i>This feature has been added to CPython and will appear in ! version CPython 1.6.</i> ! ! <p><LI>JPython formats floating point numbers differently, e.g. an upper case 'E' is used, and it switches over to E notation sooner than CPython does. <I>Both behaviors are acceptable.</I> - - <p><LI>In JPython, 0.1**4 is printed as - 1.0000000000000002E-4. In CPython, it is printed 0.0001, even - though it is not actually equal to 0.0001. <I>Both behaviors - are acceptable for now -- this is still being discussed.</I> - - <p><LI>JPython sequences support three argument - slices. i.e. range(3)[::-1] == [2,1,0]. <I>CPython should be - fixed.</I> ! <p><LI>Every object in JPython is an instance of a class -- ! there are no types in JPython. i.e. [].__class__ is a sensible ! thing to write in JPython. <I>CPython should be fixed - but don't hold your breath.</I> ! <p><LI>The .tell() method on JPython file objects returns a ! Python long, while the .tell() method on CPython file objects ! returns a Python int. <I>Whether or not both behaviors are ! acceptable is still unclear.</I> ! ! <p><LI>JPython file objects are still missing some functionality -- see todo list in PyFile.java. (Hopefully in ! the near future this can be changed to read -- JPython file objects include the following extra functionality to properly ! handle non-ascii files...) <I>JPython should be fixed.</I> <p><LI>In CPython, range(0.1, 3.2) yields the surprising [0, ! 1, 2]. JPython does the right thing (reject float arguments). -- Many other functions taking int arguments have the same ! problem. <I>CPython should be fixed.</I> ! ! <p><LI>In CPython, the list.append() method takes multiple ! arguments and forms a tuple. JPython's append() method ! requires one argument only. <I>CPython should be fixed -- but ! probably won't be due to backwards compatibility.</I> <p><LI>The __name__ attribute of built-in extension modules --- 188,236 ---- <UL> ! <LI>Jython have only one string type which support full ! two-byte Unicode characters and the functions in the string ! module are Unicode-aware. The u"" string modifier is optional ! and completely ignored if specified. ! CPython-2.0 have two string types, the classic 8-bit string and ! and new unicode string which is created with the u"" string modifier. ! <I>Both behaviors are acceptable.</I> ! ! <p><li>Jython uses the character properties (isuppercase, isdecimal, ...) ! from the java platform. Java uses Unicode-2.0 and not all unicode properties ! is available through java. ! CPython-2.0 uses Unicode-3.0 and all unicode properties are available. ! About 340 of the unicode points have different properties. ! <I>Both behaviors are acceptable.</I> ! ! <p><LI>Jython formats floating point numbers differently, e.g. an upper case 'E' is used, and it switches over to E notation sooner than CPython does. <I>Both behaviors are acceptable.</I> ! <p><LI>In Jython, 0.1**4 is printed as ! 1.0000000000000002E-4. In CPython, it is printed ! 0.00010000000000000005. ! <I>Both behaviors are acceptable.</I> ! ! <p><LI>Jython sequences support three argument ! slices. i.e. range(3)[::-1] == [2,1,0]. ! <I>CPython should be fixed.</I> ! ! <p><LI>Every object in Jython is an instance of a class -- ! there are no types in Jython. i.e. [].__class__ is a sensible ! thing to write in Jython. <I>CPython should be fixed - but don't hold your breath.</I> ! <p><LI>Jython file objects are still missing some functionality -- see todo list in PyFile.java. (Hopefully in ! the near future this can be changed to read -- Jython file objects include the following extra functionality to properly ! handle non-ascii files...) <I>Jython should be fixed.</I> <p><LI>In CPython, range(0.1, 3.2) yields the surprising [0, ! 1, 2]. Jython does the right thing (reject float arguments). -- Many other functions taking int arguments have the same ! problem. <I>CPython should be fixed, but don't hold your ! breath.</I> <p><LI>The __name__ attribute of built-in extension modules *************** *** 240,273 **** <p><LI>In many cases, introspection yields different results. ! <I>Where appropriate and possible, JPython will adhere to CPython's introspection behavior. Some differences are acceptable.</I> ! <p><LI>JPython defines __debug__, but always sets it equal to ! 1. <I>JPython should implement CPython's -O option.</I> ! <p><LI>The locals() dictionary in JPython is mutable from within a function. After "def foo(x=1): locals()['x'] = 2; print x" foo() prints 1 in CPython and 2 in ! JPython. Jim thinks that JPython's behavior is better here -- but the best answer might be that locals() should be considered a read-only dictionary.<I> Proper behavior here is still unclear.</I> ! <p><LI>JPython doesn't support restricted execution mode and doesn't have the magic __builtins__ in every namespace. ! <I>JPython will probably never support restricted execution mode -- Java's security model is recommended instead.</I> ! <p><LI>JPython uses different values for the IOError argument. This causes trouble for people who unpack the value into an (errno, message) tuple. <I>Both behaviors are acceptable.</I> ! <p><LI>JPython code objects are missing other attributes -- co_code, co_consts, co_lnotab, co_names, co_nlocals, co_stacksize. <I>co_flags is now supported because the Python debugger requires it. Other attributes will probably never be ! supported in JPython due to its implementation of code objects as compiled Java bytecodes.</I> --- 239,272 ---- <p><LI>In many cases, introspection yields different results. ! <I>Where appropriate and possible, Jython will adhere to CPython's introspection behavior. Some differences are acceptable.</I> ! <p><LI>Jython defines __debug__, but always sets it equal to ! 1. <I>Jython should implement CPython's -O option.</I> ! <p><LI>The locals() dictionary in Jython is mutable from within a function. After "def foo(x=1): locals()['x'] = 2; print x" foo() prints 1 in CPython and 2 in ! Jython. Jim thinks that Jython's behavior is better here -- but the best answer might be that locals() should be considered a read-only dictionary.<I> Proper behavior here is still unclear.</I> ! <p><LI>Jython doesn't support restricted execution mode and doesn't have the magic __builtins__ in every namespace. ! <I>Jython will probably never support restricted execution mode -- Java's security model is recommended instead.</I> ! <p><LI>Jython uses different values for the IOError argument. This causes trouble for people who unpack the value into an (errno, message) tuple. <I>Both behaviors are acceptable.</I> ! <p><LI>Jython code objects are missing other attributes -- co_code, co_consts, co_lnotab, co_names, co_nlocals, co_stacksize. <I>co_flags is now supported because the Python debugger requires it. Other attributes will probably never be ! supported in Jython due to its implementation of code objects as compiled Java bytecodes.</I> *************** *** 275,284 **** objects may raise <tt>AttributeError</tt> or <tt>TypeError</tt> differently. <i>This is considered ! implementation dependent. In JPython the following rules are used: when getting a non-existant attribute, <tt>AttributeError</tt> is raised; when setting or deleting a readonly attribute, <tt>TypeError</tt> is raised; when setting or deleting a non-existant attribute, <tt>AttributeError</tt> ! is raised. Be aware though currently neither JPython nor CPython are completely consistent.</i> --- 274,283 ---- objects may raise <tt>AttributeError</tt> or <tt>TypeError</tt> differently. <i>This is considered ! implementation dependent. In Jython the following rules are used: when getting a non-existant attribute, <tt>AttributeError</tt> is raised; when setting or deleting a readonly attribute, <tt>TypeError</tt> is raised; when setting or deleting a non-existant attribute, <tt>AttributeError</tt> ! is raised. Be aware though currently neither Jython nor CPython are completely consistent.</i> *************** *** 286,313 **** func_defaults attributes. <i>While these are writable in CPython, I haven't decided whether they should be writable in ! JPython.</i> ! <p><LI>JPython has "true" garbage collection whereas ! CPython uses reference counting. This means that in JPython users don't need to worry about handling circular references as these are guaranteed to be collected properly. On the ! other hand, users of JPython have no guarantees of when an object will be finalized -- this can cause problems for people who use open("foo", 'r').read() excessively. <I>Both behaviors are acceptable -- and highly unlikely to change.</I> - <p><LI>In JPython, __del__() methods in user-defined classes - are never called. <i>Some future version of JPython might - provide limited support for __del__(), but see the above - item.</i> - <p><LI>The dictionaries used by classes, instances, and ! modules in JPython are not the same as the dictionaries created by {}. They are StringMap's which require all of their keys to be strings. After "class c: pass", c.__dict__[1] = 2 will work in CPython, but will raise a "TypeError: keys in namespace must be strings" error ! in JPython. <I>Both behaviors are acceptable -- CPython might ! adopt JPython's approach in the future for the performance gains it can provide.</I> --- 285,307 ---- func_defaults attributes. <i>While these are writable in CPython, I haven't decided whether they should be writable in ! Jython.</i> ! <p><LI>Jython has "true" garbage collection whereas ! CPython uses reference counting. This means that in Jython users don't need to worry about handling circular references as these are guaranteed to be collected properly. On the ! other hand, users of Jython have no guarantees of when an object will be finalized -- this can cause problems for people who use open("foo", 'r').read() excessively. <I>Both behaviors are acceptable -- and highly unlikely to change.</I> <p><LI>The dictionaries used by classes, instances, and ! modules in Jython are not the same as the dictionaries created by {}. They are StringMap's which require all of their keys to be strings. After "class c: pass", c.__dict__[1] = 2 will work in CPython, but will raise a "TypeError: keys in namespace must be strings" error ! in Jython. <I>Both behaviors are acceptable -- CPython might ! adopt Jython's approach in the future for the performance gains it can provide.</I> *************** *** 317,342 **** <UL> ! <LI>JPython supports all Java packages as extension modules. i.e. from "java.lang import System" will ! work in any JPython implementation. <I>This functionality might be added as an optional extension to some future version of CPython.</I> ! <p><LI>JPython includes the builtin module <tt>jarray</tt> -- which allows Python programmers to create and manipulate Java array objects. ! <p><LI>Lots of builtin extension modules don't exist in JPython. <UL> ! <LI>Modules struct, cPickle, cStringIO, and operator were ! all added for JPython v1.1. The following are likely to ! be implemented in a future version of JPython -- cmath. ! ! <p><LI>The following are under consideration (working code would make the decision much easier ;-) -- array, select, ! a dbm/gdbm/bsddb style module, Numeric. <p><LI>The following are highly unlikely any time soon -- ! Tkinter. However, Finn Bock has a JNI implementation called <a href="http://jTkinter.sourceforge.net/">jTkinter</a> which supports the full _tkinter API. Very cool stuff! --- 311,332 ---- <UL> ! <LI>Jython supports all Java packages as extension modules. i.e. from "java.lang import System" will ! work in any Jython implementation. <I>This functionality might be added as an optional extension to some future version of CPython.</I> ! <p><LI>Jython includes the builtin module <tt>jarray</tt> -- which allows Python programmers to create and manipulate Java array objects. ! <p><LI>Some builtin extension modules don't exist in Jython. <UL> ! <LI>The following are under consideration (working code would make the decision much easier ;-) -- array, select, ! a dbm/gdbm/bsddb style module, Numeric, cmath. <p><LI>The following are highly unlikely any time soon -- ! win32com and Tkinter. However, Finn Bock has a JNI implementation called <a href="http://jTkinter.sourceforge.net/">jTkinter</a> which supports the full _tkinter API. Very cool stuff! *************** *** 346,362 **** </UL> - <p><LI>__builtin__ module - <UL> - <p><LI>Incomplete implementation of __import__ -- only one - argument is allowed and replacing this with a user-defined - function has no effect. <I>JPython might be fixed in a - future release, but CPython will probably adopt a new - import mechanism in the near future, so JPython may not - change until the new mechanism is defined.</I> - </UL> - <p><LI>os module <UL> ! <LI>popen() and system() are missing. <I>JPython should be fixed, patches would be graciously accepted.</I> --- 336,342 ---- </UL> <p><LI>os module <UL> ! <LI>popen() and system() are missing. <I>Jython should be fixed, patches would be graciously accepted.</I> *************** *** 373,381 **** <p>Finn Bock has created ! a JNI/C++ implementation for the posix module. See ! <a href="http://pip.dknet.dk/~pip1848/jpython/modules.html"> ! Finn Bock's JPython modules page</a> for details. ! Note that his cPickle, cStringIO, binascii, and struct ! modules have all been integrated into JPython 1.1. </UL> --- 353,358 ---- <p>Finn Bock has created ! a <a href="http://jnios.sourceforge.net/">JNI/C++ ! implementation for the posix module</a> </UL> *************** *** 385,392 **** <UL> ! <p><LI>JPython is still missing exitfunc <p><LI>Also missing executable, getrefcount, ! setcheckinterval which don't make much sense for JPython. </UL> --- 362,369 ---- <UL> ! <p><LI>Jython is still missing exitfunc <p><LI>Also missing executable, getrefcount, ! setcheckinterval which don't make much sense for Jython. </UL> *************** *** 395,400 **** <UL> <p><LI>CPython's thread modules defines some aliases that ! JPython's doesn't. <I>These aliases are considered ! obsolete and won't be supported by JPython.</I> </UL> --- 372,377 ---- <UL> <p><LI>CPython's thread modules defines some aliases that ! Jython's doesn't. <I>These aliases are considered ! obsolete and won't be supported by Jython.</I> </UL> *************** *** 411,418 **** <UL> ! <p><LI>JPython doesn't catch interrupts. <I>Only fixable with a GUI console since interrupts are not supported by Java.</I> ! <p><LI>JPython doesn't have command line editing. <I>Only fixable with a GUI console. However, Un*x users can check out <tt>rlterm</tt> which provides generic GNU Readline support --- 388,395 ---- <UL> ! <p><LI>Jython doesn't catch interrupts. <I>Only fixable with a GUI console since interrupts are not supported by Java.</I> ! <p><LI>Jython doesn't have command line editing. <I>Only fixable with a GUI console. However, Un*x users can check out <tt>rlterm</tt> which provides generic GNU Readline support *************** *** 421,429 **** <a href="ftp://ftp-icf.llnl.gov/pub/Yorick/">Yorick</a> package.</I> ! <p><LI>JPython should have a feature similar to $PYTHONSTARTUP, which specifies a script to run at the start of interactive mode only. ! <p><LI>JPython supports <a href="interpreter.html">different command line options</a> than CPython, e.g. "-jar" and "-D". It --- 398,406 ---- <a href="ftp://ftp-icf.llnl.gov/pub/Yorick/">Yorick</a> package.</I> ! <p><LI>Jython should have a feature similar to $PYTHONSTARTUP, which specifies a script to run at the start of interactive mode only. ! <p><LI>Jython supports <a href="interpreter.html">different command line options</a> than CPython, e.g. "-jar" and "-D". It Index: embedding.html =================================================================== RCS file: /cvsroot/jython/jython/Doc/embedding.html,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** embedding.html 1999/06/17 20:30:45 1.4 --- embedding.html 2000/11/17 14:14:17 1.5 *************** *** 1,12 **** <HTML> <!-- THIS PAGE IS AUTOMATICALLY GENERATED. DO NOT EDIT. --> ! <!-- USING THE NEW HT2HTML SCRIPT: Thu Jun 17 15:59:40 1999 --> <!-- User-specified headers: ! Title: Embedding JPython --> <HEAD> ! <TITLE>Embedding JPython</TITLE> </HEAD> --- 1,14 ---- <HTML> <!-- THIS PAGE IS AUTOMATICALLY GENERATED. DO NOT EDIT. --> ! <!-- Fri Nov 17 14:50:49 2000 --> ! <!-- USING HT2HTML 1.1 --> ! <!-- SEE http://www.python.org/~bwarsaw/software/pyware.html --> <!-- User-specified headers: ! Title: Embedding Jython --> <HEAD> ! <TITLE>Embedding Jython</TITLE> </HEAD> *************** *** 23,28 **** <center> ! <a href="http://www.jpython.org/"> ! <img border=0 src="./images/jpython-new-small.gif"></a></center> </TD> <TD WIDTH=15 BGCOLOR="#cdb7b5"> </TD><!--spacer--> <!-- end of corner cells --> --- 25,30 ---- <center> ! <a href="http://jython.sourceforge.net/"> ! <img border=0 src="./images/jython-new-small.gif"></a></center> </TD> <TD WIDTH=15 BGCOLOR="#cdb7b5"> </TD><!--spacer--> <!-- end of corner cells --> *************** *** 35,39 **** <TR> <TD BGCOLOR="#cdb7b5"> ! <a href="http://www.jpython.org/">Home</a> </TD> <TD BGCOLOR="#cdb7b5"> --- 37,41 ---- <TR> <TD BGCOLOR="#cdb7b5"> ! <a href="http://jython.sourceforge.net/">Home</a> </TD> <TD BGCOLOR="#cdb7b5"> *************** *** 42,46 **** </TR><TR> <TD BGCOLOR="#cdb7b5"> ! <a href="http://www.jpython.org/download.html">Download</a> </TD> <TD BGCOLOR="#cdb7b5"> --- 44,48 ---- </TR><TR> <TD BGCOLOR="#cdb7b5"> ! <a href="http://jython.sourceforge.net/download.html">Download</a> </TD> <TD BGCOLOR="#cdb7b5"> *************** *** 68,75 **** </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="interpreter.html">Invoking JPython</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="registry.html">JPython Registry</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> --- 70,77 ---- </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="interpreter.html">Invoking Jython</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="registry.html">Jython Registry</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> *************** *** 77,81 **** </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="compile.html">Compiling JPython from source</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> --- 79,83 ---- </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="compile.html">Compiling Jython from source</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> *************** *** 96,100 **** </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="jpythonc.html">Building applets, servlets, beans...</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> --- 98,102 ---- </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="jythonc.html">Building applets, servlets, beans...</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> *************** *** 113,123 **** </FONT></B></TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="differences.html">JPython vs. CPython</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="faq.html">JPython FAQ</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="http://www.python.org/pipermail/jpython-interest/">List Archives</A> (exit) </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> --- 115,125 ---- </FONT></B></TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="differences.html">Jython vs. CPython</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="faq.html">Jython FAQ</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="http://www.geocrawler.com/archives/3/7017/2000/">List Archives</A> (exit) </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> *************** *** 129,133 **** </FONT></B></TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="mailto:jp...@py...">jp...@py...</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> --- 131,135 ---- </FONT></B></TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="mailto:jyt...@li...">jyt...@li...</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> *************** *** 140,143 **** --- 142,148 ---- </A> </TD></TR> + <TR><TD BGCOLOR="#cdb7b5"> + + </TD></TR> </TABLE><!-- end of sidebar table --> *************** *** 147,156 **** <!-- start of body cell --> <TD VALIGN=TOP WIDTH="90%"><BR> ! <h3>Embedding JPython</h3> ! <P>There are several options for embedding JPython in a Java application. Sometimes the nicest approach is to make a real Java class out of a Python class and then just use that Python class from ! Java code. The simplest approach to embedding JPython is to use the PythonInterpreter object.</P> --- 152,161 ---- <!-- start of body cell --> <TD VALIGN=TOP WIDTH="90%"><BR> ! <h3>Embedding Jython</h3> ! <P>There are several options for embedding Jython in a Java application. Sometimes the nicest approach is to make a real Java class out of a Python class and then just use that Python class from ! Java code. The simplest approach to embedding Jython is to use the PythonInterpreter object.</P> Index: faq.html =================================================================== RCS file: /cvsroot/jython/jython/Doc/faq.html,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** faq.html 2000/01/22 01:09:35 1.10 --- faq.html 2000/11/17 14:14:17 1.11 *************** *** 1,14 **** <HTML> <!-- THIS PAGE IS AUTOMATICALLY GENERATED. DO NOT EDIT. --> ! <!-- Fri Jan 21 20:05:34 2000 --> <!-- USING HT2HTML 1.1 --> <!-- SEE http://www.python.org/~bwarsaw/software/pyware.html --> <!-- User-specified headers: ! Title: JPython FAQ --> <HEAD> ! <TITLE>JPython FAQ</TITLE> </HEAD> --- 1,14 ---- <HTML> <!-- THIS PAGE IS AUTOMATICALLY GENERATED. DO NOT EDIT. --> ! <!-- Fri Nov 17 14:50:49 2000 --> <!-- USING HT2HTML 1.1 --> <!-- SEE http://www.python.org/~bwarsaw/software/pyware.html --> <!-- User-specified headers: ! Title: Jython FAQ --> <HEAD> ! <TITLE>Jython FAQ</TITLE> </HEAD> *************** *** 25,30 **** <center> ! <a href="http://www.jpython.org/"> ! <img border=0 src="./images/jpython-new-small.gif"></a></center> </TD> <TD WIDTH=15 BGCOLOR="#cdb7b5"> </TD><!--spacer--> <!-- end of corner cells --> --- 25,30 ---- <center> ! <a href="http://jython.sourceforge.net/"> ! <img border=0 src="./images/jython-new-small.gif"></a></center> </TD> <TD WIDTH=15 BGCOLOR="#cdb7b5"> </TD><!--spacer--> <!-- end of corner cells --> *************** *** 37,41 **** <TR> <TD BGCOLOR="#cdb7b5"> ! <a href="http://www.jpython.org/">Home</a> </TD> <TD BGCOLOR="#cdb7b5"> --- 37,41 ---- <TR> <TD BGCOLOR="#cdb7b5"> ! <a href="http://jython.sourceforge.net/">Home</a> </TD> <TD BGCOLOR="#cdb7b5"> *************** *** 44,48 **** </TR><TR> <TD BGCOLOR="#cdb7b5"> ! <a href="http://www.jpython.org/download.html">Download</a> </TD> <TD BGCOLOR="#cdb7b5"> --- 44,48 ---- </TR><TR> <TD BGCOLOR="#cdb7b5"> ! <a href="http://jython.sourceforge.net/download.html">Download</a> </TD> <TD BGCOLOR="#cdb7b5"> *************** *** 70,77 **** </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="interpreter.html">Invoking JPython</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="registry.html">JPython Registry</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> --- 70,77 ---- </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="interpreter.html">Invoking Jython</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="registry.html">Jython Registry</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> *************** *** 79,83 **** </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="compile.html">Compiling JPython from source</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> --- 79,83 ---- </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="compile.html">Compiling Jython from source</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> *************** *** 98,102 **** </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="jpythonc.html">Building applets, servlets, beans...</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> --- 98,102 ---- </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="jythonc.html">Building applets, servlets, beans...</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> *************** *** 115,125 **** </FONT></B></TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="differences.html">JPython vs. CPython</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <b>JPython FAQ</b> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="http://www.python.org/pipermail/jpython-interest/">List Archives</A> (exit) </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> --- 115,125 ---- </FONT></B></TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="differences.html">Jython vs. CPython</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <b>Jython FAQ</b> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="http://www.geocrawler.com/archives/3/7017/2000/">List Archives</A> (exit) </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> *************** *** 131,135 **** </FONT></B></TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="mailto:jp...@py...">jp...@py...</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> --- 131,135 ---- </FONT></B></TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="mailto:jyt...@li...">jyt...@li...</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> *************** *** 142,145 **** --- 142,148 ---- </A> </TD></TR> + <TR><TD BGCOLOR="#cdb7b5"> + + </TD></TR> </TABLE><!-- end of sidebar table --> *************** *** 149,153 **** <!-- start of body cell --> <TD VALIGN=TOP WIDTH="90%"><BR> ! <h3>The JPython FAQ</h3> <ol> --- 152,156 ---- <!-- start of body cell --> <TD VALIGN=TOP WIDTH="90%"><BR> ! <h3>The Jython FAQ</h3> <ol> *************** *** 162,179 **** JPython. ! <p><li><b>Is JPython the same language as Python?</b> ! <P>We will always strive to ensure that JPython remains as compatible with CPython as possible. Nevertheless, there are a number of <a href="differences.html">differences</a> between the two implementations that are ! unlikely to go away. These range from the trivial - JPython's code objects don't have a co_code attribute because they don't ! have any Python bytecodes; to the significant - JPython uses Java's true garbage collection rather than Python's reference counting scheme. <P>Python has never really had much of a language definition ! beyond it's C-based implementation. The existence of JPython changed that for the first time and will hopefully lead to a much clearer sense of what Python the language is; independent of any --- 165,194 ---- JPython. ! <p><li><b>What is Jython?</b> ! ! <p>Jython is the successor to JPython. The Jython project was ! created in accordance with the CNRI JPython 1.1.x license, in ! order to ensure the continued existence and development of this ! important piece of Python software. The intent is to manage this ! project with the same open policies that are serving CPython so well. ! ! <p>Mailing lists, CVS and all current information on the Jython ! project is available at SourceForge, at ! <a href="http://sourceforge.net/projects/jython">The Jython project</a>. ! ! <p><li><b>Is Jython the same language as Python?</b> ! <P>We will always strive to ensure that Jython remains as compatible with CPython as possible. Nevertheless, there are a number of <a href="differences.html">differences</a> between the two implementations that are ! unlikely to go away. These range from the trivial - Jython's code objects don't have a co_code attribute because they don't ! have any Python bytecodes; to the significant - Jython uses Java's true garbage collection rather than Python's reference counting scheme. <P>Python has never really had much of a language definition ! beyond it's C-based implementation. The existence of Jython changed that for the first time and will hopefully lead to a much clearer sense of what Python the language is; independent of any *************** *** 186,203 **** <p><li><b>What is the current status of JPython?</b> ! <p>JPython 1.1rc1 was released on 21-Jan-2000, with the final ! release expected before the ! <a href="http://www.python.org/workshops/2000-01/">8th ! International Python Conference</a>. Check the ! <a href="http://www.jpython.org">www.jpython.org</a> site for the ! most current release. ! Jim Hugunin, JPython's author, has moved out to sunny ! California to work on Xerox PARC's ! <a href="http://www.parc.xerox.com/spl/projects/aop/">AspectJ</a> ! language. JPython continues to be maintained by Barry Warsaw at ! CNRI, with help and input from Python's author Guido van Rossum, ! other CNRI folks, and the many contributors on the ! <a href="http://www.python.org/mailman/listinfo/jpython-interest"> ! JPython-Interest</a> mailing list. <p><li><b>JPython and Y2K</b> --- 201,210 ---- <p><li><b>What is the current status of JPython?</b> ! <p>JPython 1.1 was released on 28-Jan-2000. Since then, there have ! been no further developments on JPython. ! ! <p><li><b>What is the current status of Jython?</b> ! <p>The Jython project was announced on 19-oct-2000. A release of ! jython-2.0 is planned before the end of the year. <p><li><b>JPython and Y2K</b> *************** *** 207,214 **** <a href="http://www.python.org/cgi-bin/faqw.py?querytype=anykeywords&casefold=yes&req=search&query=y2k"> Python FAQ entry on the subject</a>, with the additional caveat ! that JPython is of course dependent on any Y2K issues associated with the underlying JVM and Java class libraries you're using. However, you can essentially apply the Python Y2K stance to ! JPython by, e.g. substituting the word "Java" for "C" in FAQ question 4.65 (<em>ignore the clip from the Python copyright notice</em>). --- 214,221 ---- <a href="http://www.python.org/cgi-bin/faqw.py?querytype=anykeywords&casefold=yes&req=search&query=y2k"> Python FAQ entry on the subject</a>, with the additional caveat ! that Jython is of course dependent on any Y2K issues associated with the underlying JVM and Java class libraries you're using. However, you can essentially apply the Python Y2K stance to ! Jython by, e.g. substituting the word "Java" for "C" in FAQ question 4.65 (<em>ignore the clip from the Python copyright notice</em>). *************** *** 217,221 **** library are supported?</b> ! <P>The good news is that JPython now supports the large majority of the standard Python library. The bad news is that this has moved so rapidly, it's hard to keep the documentation up to --- 224,228 ---- library are supported?</b> ! <P>The good news is that Jython now supports the large majority of the standard Python library. The bad news is that this has moved so rapidly, it's hard to keep the documentation up to *************** *** 223,227 **** <p>Built-in modules (e.g. those that are written in C for CPython) ! are a differnet story. These would have to be ported to Java, or implemented with a JNI bridge in order to be used by JPython. Some built-in modules have been ported to JPython, most notably --- 230,234 ---- <p>Built-in modules (e.g. those that are written in C for CPython) ! are a different story. These would have to be ported to Java, or implemented with a JNI bridge in order to be used by JPython. Some built-in modules have been ported to JPython, most notably *************** *** 237,243 **** <P>If there is some standard Python module that you have a real need for that doesn't work with JPython yet, please ! <a href="mailto:jp...@py...">send us mail</a>. ! <p><li><b>How fast is JPython?</b> <p>At <a href="http://www.python.org/workshops/1997-10/">IPC-6</a> --- 244,250 ---- <P>If there is some standard Python module that you have a real need for that doesn't work with JPython yet, please ! <a href="mailto:jyt...@li...">send us mail</a>. ! <p><li><b>How fast is Jython?</b> <p>At <a href="http://www.python.org/workshops/1997-10/">IPC-6</a> *************** *** 247,262 **** CPython is 1.5.2 which might be only slightly faster than 1.5. JimH re-ran his benchmark tests against CPython 1.5 and his then ! current release of JPython, finding that JPython was about 2.5x slower than CPython 1.5. I have recently run a few informal benchmarks and found some interesting numbers: using Sun's JDK ! 1.2.1 with JIT on a Solaris 2.6 Sparc Ultra 2, I found JPython 1.1beta3 to produce pystone numbers equal to (or very slightly better than) CPython 1.5.2+. <p>The problem, of course, is that JITs are still not reliable ! enough for JPython. Turning off the JIT on the above platform, ! can slow JPython down by a factor of 10. ! <P>The speed of JPython is tied very tightly to the speed of the underlying JVM. The benchmark results that JimH reported were all using Microsoft's JVM from Internet Explorer 4.0. The next --- 254,269 ---- CPython is 1.5.2 which might be only slightly faster than 1.5. JimH re-ran his benchmark tests against CPython 1.5 and his then ! current release of Jython, finding that Jython was about 2.5x slower than CPython 1.5. I have recently run a few informal benchmarks and found some interesting numbers: using Sun's JDK ! 1.2.1 with JIT on a Solaris 2.6 Sparc Ultra 2, I found Jython 1.1beta3 to produce pystone numbers equal to (or very slightly better than) CPython 1.5.2+. <p>The problem, of course, is that JITs are still not reliable ! enough for Jython. Turning off the JIT on the above platform, ! can slow Jython down by a factor of 10. ! <P>The speed of Jython is tied very tightly to the speed of the underlying JVM. The benchmark results that JimH reported were all using Microsoft's JVM from Internet Explorer 4.0. The next *************** *** 267,281 **** <P>Finally, pystone is not the last word in benchmarking. At the ! moment I'm more concerned with making JPython complete and correct than with performance. We will continually be revisiting performance issues both to examine better benchmark's for ! comparing JPython and CPython (as well as other scripting ! languages for the JVM) and work at optimizing JPython's performance. ! <p><li><b>Why do weird things sometimes happen in JPython?</b> <p>More likely than not, the problem is with the JIT ! (Just-in-time) compiler your JVM is using. JPython acts like a bizarre Java compiler, taking Python source code and emitting Java bytecode. It's bizarre because the emitted bytecode --- 274,288 ---- <P>Finally, pystone is not the last word in benchmarking. At the ! moment I'm more concerned with making Jython complete and correct than with performance. We will continually be revisiting performance issues both to examine better benchmark's for ! comparing Jython and CPython (as well as other scripting ! languages for the JVM) and work at optimizing Jython's performance. ! <p><li><b>Why do weird things sometimes happen in Jython?</b> <p>More likely than not, the problem is with the JIT ! (Just-in-time) compiler your JVM is using. Jython acts like a bizarre Java compiler, taking Python source code and emitting Java bytecode. It's bizarre because the emitted bytecode *************** *** 285,290 **** stuff happen, or weird bugs, the first thing to do is to turn off your JIT and try again. If the bug still exists with the JIT ! turned off then consider <a href="http://www.python.org/jpython-bugs"> ! submitting a bug report</a>. <p><li><b>Why did I get an OutOfMemoryError?</b> --- 292,298 ---- stuff happen, or weird bugs, the first thing to do is to turn off your JIT and try again. If the bug still exists with the JIT ! turned off then consider ! <a href="http://sourceforge.net/bugs/?group_id=12867">submitting a ! bug report</a>. <p><li><b>Why did I get an OutOfMemoryError?</b> *************** *** 312,316 **** (i.e. <tt>jview.exe</tt>) which provides the standard classes in a different format. You need to run the following command in a ! console window before using JPython: <pre> --- 320,324 ---- (i.e. <tt>jview.exe</tt>) which provides the standard classes in a different format. You need to run the following command in a ! console window before using Jython: <pre> *************** *** 318,324 **** </pre> ! <p><li><b>Semantic Differences between JPython and CPython</b> ! <P>There are several several differences between JPython and CPython that wil probably never go away. These differences are primarily related to underlying differences between the C and Java --- 326,332 ---- </pre> ! <p><li><b>Semantic Differences between Jython and CPython</b> ! <P>There are several several differences between Jython and CPython that wil probably never go away. These differences are primarily related to underlying differences between the C and Java *************** *** 329,338 **** <p><UL> ! <LI><em>JPython has true garbage collection - CPython uses reference counting.</em> ! <br>This means that in JPython users don't need to worry about creating circular references as these are guarnteed to be ! collected properly. On the other hand, users of JPython have no guarantees of when an object will be finalized (short of calling System.gc() to force garbage collection). --- 337,346 ---- <p><UL> ! <LI><em>Jython has true garbage collection - CPython uses reference counting.</em> ! <br>This means that in Jython users don't need to worry about creating circular references as these are guarnteed to be ! collected properly. On the other hand, users of Jython have no guarantees of when an object will be finalized (short of calling System.gc() to force garbage collection). *************** *** 344,348 **** ever called. ! <p><LI><em>Control-C can not be caught by JPython, but will exit the shell completely</em> </UL> --- 352,356 ---- ever called. ! <p><LI><em>Control-C can not be caught by Jython, but will exit the shell completely</em> </UL> *************** *** 350,354 **** <p><li><b>Why can't I multiply inherit from two Java classes?</b> ! <P>In an earlier version of JPython, you actually could. This was deliberately disabled in 1.1 for a variety of good reasons. For a detailed discussion on this issue see the following archive --- 358,362 ---- <p><li><b>Why can't I multiply inherit from two Java classes?</b> ! <P>In earlier versions of JPython, you actually could. This was deliberately disabled in 1.1 for a variety of good reasons. For a detailed discussion on this issue see the following archive Index: index.html =================================================================== RCS file: /cvsroot/jython/jython/Doc/index.html,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** index.html 1999/09/10 16:49:41 1.5 --- index.html 2000/11/17 14:14:17 1.6 *************** *** 1,14 **** <HTML> <!-- THIS PAGE IS AUTOMATICALLY GENERATED. DO NOT EDIT. --> ! <!-- Fri Sep 10 12:47:52 1999 --> ! <!-- USING HT2HTML 1.0 --> <!-- SEE http://www.python.org/~bwarsaw/software/pyware.html --> <!-- User-specified headers: ! Title: Overview of JPython documentation --> <HEAD> ! <TITLE>Overview of JPython documentation</TITLE> </HEAD> --- 1,14 ---- <HTML> <!-- THIS PAGE IS AUTOMATICALLY GENERATED. DO NOT EDIT. --> ! <!-- Fri Nov 17 14:50:49 2000 --> ! <!-- USING HT2HTML 1.1 --> <!-- SEE http://www.python.org/~bwarsaw/software/pyware.html --> <!-- User-specified headers: ! Title: Overview of Jython documentation --> <HEAD> ! <TITLE>Overview of Jython documentation</TITLE> </HEAD> *************** *** 25,30 **** <center> ! <a href="http://www.jpython.org/"> ! <img border=0 src="./images/jpython-new-small.gif"></a></center> </TD> <TD WIDTH=15 BGCOLOR="#cdb7b5"> </TD><!--spacer--> <!-- end of corner cells --> --- 25,30 ---- <center> ! <a href="http://jython.sourceforge.net/"> ! <img border=0 src="./images/jython-new-small.gif"></a></center> </TD> <TD WIDTH=15 BGCOLOR="#cdb7b5"> </TD><!--spacer--> <!-- end of corner cells --> *************** *** 37,41 **** <TR> <TD BGCOLOR="#cdb7b5"> ! <a href="http://www.jpython.org/">Home</a> </TD> <TD BGCOLOR="#cdb7b5"> --- 37,41 ---- <TR> <TD BGCOLOR="#cdb7b5"> ! <a href="http://jython.sourceforge.net/">Home</a> </TD> <TD BGCOLOR="#cdb7b5"> *************** *** 44,51 **** </TR><TR> <TD BGCOLOR="#cdb7b5"> ! <a href="http://www.jpython.org/download.html">Download</a> </TD> <TD BGCOLOR="#cdb7b5"> ! <a href="./index.html">Documentation</a> </TD> </TR> --- 44,51 ---- </TR><TR> <TD BGCOLOR="#cdb7b5"> ! <a href="http://jython.sourceforge.net/download.html">Download</a> </TD> <TD BGCOLOR="#cdb7b5"> ! <b>Documentation</b> </TD> </TR> *************** *** 70,77 **** </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="interpreter.html">Invoking JPython</A> </TD></TR> <TR><TD BGCOLOR="#cdb7b5"> ! <A HREF="registry.html">JPython Regis... [truncated message content] |
From: Finn B. <bc...@us...> - 2000-11-17 14:12:42
|
Update of /cvsroot/jython/jython/Doc/images In directory slayer.i.sourceforge.net:/tmp/cvs-serv15529 Added Files: jython-new-small.gif Log Message: A temporary logo. --- NEW FILE --- GIF89a Qz0 `«èèxéZ ì×CN»Qc¬µ^kytÙ>Ýå@ÛîdÛë]§GÔÄ Eþ¡qTäF'{µÕV]v÷UYge ÂiRh\d«¬A è×êävKm8B~sùsuÐ 9A{Èc/oébdï± `UÇ$Í(|2àÙìâ/YåcßôèÆäo&¥@^ýØcÍ}9mUV Ã¥ ÝI^Çò«cÆ&bcW0*ëì6\ÂÔ³Ôö U[mqS í·Ø,¸äkî¹è¦«îºì¶ëî»ðÖ |
From: Samuele P. <ped...@us...> - 2000-11-17 12:44:24
|
Update of /cvsroot/jython/jython/Tools/jythonc In directory slayer.i.sourceforge.net:/tmp/cvs-serv2198/jythonc Modified Files: ImportName.py compile.py depend.py jar.py javac.py main.py util.py Added Files: yapm.py Log Message: Loading logic fixes: jythonc-side. For issues involved see the jython-dev list archives. --- NEW FILE --- # see org.python.core.SysPackageManager import sys import os from string import strip from java import io from org.python.core import PathPackageManager class YaPM(PathPackageManager): def __init__(self, registry): self.findAllPackages(registry) def findClass(self, pkg, name): return None def findAllPackages(self,registry): paths = registry.getProperty("python.packages.paths","java.class.path") paths = paths.split(',') # opt if "sun.boot.class.path" in paths: # ??pending strip boot class paths of other jvms? paths.remove("sun.boot.class.path") fakepath = registry.getProperty("python.packages.fakepath", None) for p in paths: e = registry.getProperty(p) if e != None: self.addClassPath(e) if fakepath != None: self.addClassPath(fakepath) def filterByName(self,name,pkg): return 0 def filterByAccess(self,name,acc): return not ((name.find('$') != -1) or (acc & 1 == 0)) def doDir(self, jpkg, instantiate, exclpkgs): basic = self.basicDoDir(jpkg, 0, exclpkgs) ret = [] self.super__doDir(self.searchPath,ret,jpkg,0,exclpkgs) self.super__doDir(sys.path,ret,jpkg,0,exclpkgs) return self.merge(basic,ret) def packageExists(self,pkg,name): return self.super__packageExists(self.searchPath,pkg,name) or self.super__packageExists(sys.path,pkg,name) Index: ImportName.py =================================================================== RCS file: /cvsroot/jython/jython/Tools/jythonc/ImportName.py,v retrieving revision 2.3 retrieving revision 2.4 diff -C2 -r2.3 -r2.4 *** ImportName.py 2000/10/13 19:06:57 2.3 --- ImportName.py 2000/11/17 12:44:21 2.4 *************** *** 5,9 **** from org.python.core import PyModule, PyJavaClass, PyClass, \ ! PyJavaPackage, PyBeanEventProperty, PyJavaDirPackage from util import lookup --- 5,9 ---- from org.python.core import PyModule, PyJavaClass, PyClass, \ ! PyJavaPackage, PyBeanEventProperty from util import lookup *************** *** 20,25 **** elif isinstance(mod, PyJavaPackage): return Package(mod) - elif isinstance(mod, PyJavaDirPackage): - return Package(mod) else: return Namespace(mod) --- 20,23 ---- *************** *** 89,92 **** --- 87,91 ---- + from util import reportPublicPlainClasses class Package(Namespace): _classes = {} *************** *** 94,98 **** apply(Namespace.__init__, (self, mod)+args) if isinstance(mod, PyJavaPackage): ! classes = PyJavaPackage._unparsedAll._doget(self.mod) if classes: self._classes[self.name] = classes --- 93,98 ---- apply(Namespace.__init__, (self, mod)+args) if isinstance(mod, PyJavaPackage): ! ## classes = PyJavaPackage._unparsedAll._doget(self.mod) ! classes = reportPublicPlainClasses(self.mod) if classes: self._classes[self.name] = classes Index: compile.py =================================================================== RCS file: /cvsroot/jython/jython/Tools/jythonc/compile.py,v retrieving revision 2.12 retrieving revision 2.13 diff -C2 -r2.12 -r2.13 *** compile.py 2000/11/10 14:57:45 2.12 --- compile.py 2000/11/17 12:44:21 2.13 *************** *** 99,111 **** ! def makeArrayName(c): ! if c.endswith("[]"): ! return "["+makeArrayName(c[:-2]) ! else: ! if primNames.has_key(c): ! return primNames[c] ! else: ! return "L"+c+";" def getJavaClass(c): if isinstance(c, StringType): --- 99,112 ---- ! ##def makeArrayName(c): ! ## if c.endswith("[]"): ! ## return "["+makeArrayName(c[:-2]) ! ## else: ! ## if primNames.has_key(c): ! ## return primNames[c] ! ## else: ! ## return "L"+c+";" + import util def getJavaClass(c): if isinstance(c, StringType): *************** *** 113,123 **** return primitives[c] if c.endswith("[]"): ! return Class.forName(makeArrayName(c)) try: ! return Class.forName(c) except: return None elif isinstance(c, ImportName.JavaClass): ! return Class.forName(c.name) elif isinstance(c, Class): return c --- 114,125 ---- return primitives[c] if c.endswith("[]"): ! # java1.1 allows only this ! return Class.getClass(reflect.Array.newInstance(getJavaClass(c[:-2]),0)) try: ! return util.findClass(c) #Class.forName(c) except: return None elif isinstance(c, ImportName.JavaClass): ! return c.mod #Class.forName(c.name) elif isinstance(c, Class): return c Index: depend.py =================================================================== RCS file: /cvsroot/jython/jython/Tools/jythonc/depend.py,v retrieving revision 2.3 retrieving revision 2.4 diff -C2 -r2.3 -r2.4 *** depend.py 2000/10/13 18:56:36 2.3 --- depend.py 2000/11/17 12:44:21 2.4 *************** *** 101,115 **** from util import lookup, getzip def getFile(name): dot = name.rfind('.') if dot == -1: ! return topFile(name) package = lookup(name[:dot]) ! if hasattr(package, '__file__'): ! return ZipEntry(package.__file__, name) ! elif hasattr(package, '__path__') and len(package.__path__) == 1: ! return DirEntry(package.__path__[0], name) elif isinstance(package, TypeType): # this 'package' is a java class --- 101,120 ---- + from org.python.core import PyJavaPackage from util import lookup, getzip + from util import openResource def getFile(name): dot = name.rfind('.') if dot == -1: ! return PkgEntry(name) ! ## return topFile(name) package = lookup(name[:dot]) ! if isinstance(package, PyJavaPackage): ! return PkgEntry(name) ! ## if hasattr(package, '__file__'): ! ## return ZipEntry(package.__file__, name) ! ## elif hasattr(package, '__path__') and len(package.__path__) == 1: ! ## return DirEntry(package.__path__[0], name) elif isinstance(package, TypeType): # this 'package' is a java class *************** *** 118,150 **** return f ! ! ! class ZipEntry: ! def __init__(self, filename, classname): ! self.filename = filename self.classname = classname def __repr__(self): ! return "ZipEntry(%s, %s)" % (self.filename, self.classname) def getInputStream(self): ! zf = getzip(self.filename) ! zfilename = unfix(self.classname) + '.class' ! entry = zf.getEntry(zfilename) ! return zf.getInputStream(entry) ! class DirEntry: ! def __init__(self, dirname, classname): ! self.dirname = dirname ! self.classname = classname ! ! def __repr__(self): ! return "DirEntry(%s, %s)" % (self.dirname, self.classname) ! ! def getInputStream(self): ! lastname = self.classname.split('.')[-1] ! fullname = os.path.join(self.dirname, lastname+'.class') ! return io.FileInputStream(fullname) --- 123,165 ---- return f ! class PkgEntry: ! def __init__(self, classname): self.classname = classname def __repr__(self): ! return "PkgEntry(%s)" % (self.classname) def getInputStream(self): ! res = unfix(self.classname) + '.class' ! return openResource(res) ! ##class ZipEntry: ! ## def __init__(self, filename, classname): ! ## self.filename = filename ! ## self.classname = classname ! ## ! ## def __repr__(self): ! ## return "ZipEntry(%s, %s)" % (self.filename, self.classname) ! ## ! ## def getInputStream(self): ! ## zf = getzip(self.filename) ! ## zfilename = unfix(self.classname) + '.class' ! ## entry = zf.getEntry(zfilename) ! ## return zf.getInputStream(entry) ! ## ! ## ! ##class DirEntry: ! ## def __init__(self, dirname, classname): ! ## self.dirname = dirname ! ## self.classname = classname ! ## ! ## def __repr__(self): ! ## return "DirEntry(%s, %s)" % (self.dirname, self.classname) ! ## ! ## def getInputStream(self): ! ## lastname = self.classname.split('.')[-1] ! ## fullname = os.path.join(self.dirname, lastname+'.class') ! ## return io.FileInputStream(fullname) Index: jar.py =================================================================== RCS file: /cvsroot/jython/jython/Tools/jythonc/jar.py,v retrieving revision 2.4 retrieving revision 2.5 diff -C2 -r2.4 -r2.5 *** jar.py 2000/10/13 18:56:00 2.4 --- jar.py 2000/11/17 12:44:21 2.5 *************** *** 7,10 **** --- 7,11 ---- from java.io import * from util import lookup + from util import listAllClasses, openResource DOT = '.' *************** *** 98,149 **** self.zipfile.close() ! # add just one class from a package ! def addOneClass(self, pkgclass): ! parts = pkgclass.split('.') ! package = DOT.join(parts[:-1]) pkg = lookup(package) ! filename = os.path.join(pkg.__path__[0], parts[-1]) + '.class' ! entryname = '/'.join(parts) + '.class' ! self.zipfile.putNextEntry(ZipEntry(entryname)) ! instream = FileInputStream(filename) ! copy(instream, self.zipfile) ! instream.close() ! ! # The next three methods handle packages (typically org.python.core, ...) ! def addPackage(self, package, skiplist=[]): ! pkg = lookup(package) ! if hasattr(pkg, '__file__'): ! return self.addZipPackage(package+'.', pkg.__file__, skiplist) ! elif hasattr(pkg, '__path__') and len(pkg.__path__) == 1: ! return self.addDirectoryPackage(package+'.', ! pkg.__path__[0], skiplist) ! raise ValueError, "can't find package: "+repr(package) ! ! def addZipPackage(self, package, zipfile, skiplist): ! zf = ZipFile(zipfile) ! for entry in zf.entries(): ! filename = entry.name ! if filename[-6:] != '.class': ! continue ! name = filename[:-6].replace(SLASH, DOT) ! ! if name[:len(package)] != package: ! continue ! self.zipfile.putNextEntry(ZipEntry(filename)) ! copy(zf.getInputStream(entry), self.zipfile) ! zf.close() ! ! def addDirectoryPackage(self, package, directory, skiplist): ! for file in os.listdir(directory): ! if file[-6:] != '.class': ! continue ! name = package+file[:-6] if name in skiplist: continue ! entryname = SLASH.join(name.split('.')) + '.class' self.zipfile.putNextEntry(ZipEntry(entryname)) ! instream = FileInputStream(os.path.join(directory, file)) copy(instream, self.zipfile) instream.close() --- 99,165 ---- self.zipfile.close() ! # handle packages (typically org.python.core, ...) ! def addPackage(self, package, skiplist = []): pkg = lookup(package) ! base = package.replace(DOT,SLASH) ! for cl in listAllClasses(pkg): ! name = package+ '.' +cl if name in skiplist: + # print 'skipping',name # ?? dbg continue ! entryname = base +'/' + cl + '.class' self.zipfile.putNextEntry(ZipEntry(entryname)) ! instream = openResource(entryname) copy(instream, self.zipfile) instream.close() + + ## # add just one class from a package + ## def addOneClass(self, pkgclass): + ## parts = pkgclass.split('.') + ## package = DOT.join(parts[:-1]) + ## pkg = lookup(package) + ## filename = os.path.join(pkg.__path__[0], parts[-1]) + '.class' + ## entryname = '/'.join(parts) + '.class' + ## self.zipfile.putNextEntry(ZipEntry(entryname)) + ## instream = FileInputStream(filename) + ## copy(instream, self.zipfile) + ## instream.close() + ## + ## # The next three methods handle packages (typically org.python.core, ...) + ## def addPackage(self, package, skiplist=[]): + ## pkg = lookup(package) + ## if hasattr(pkg, '__file__'): + ## return self.addZipPackage(package+'.', pkg.__file__, skiplist) + ## elif hasattr(pkg, '__path__') and len(pkg.__path__) == 1: + ## return self.addDirectoryPackage(package+'.', + ## pkg.__path__[0], skiplist) + ## raise ValueError, "can't find package: "+repr(package) + ## + ## def addZipPackage(self, package, zipfile, skiplist): + ## zf = ZipFile(zipfile) + ## for entry in zf.entries(): + ## filename = entry.name + ## if filename[-6:] != '.class': + ## continue + ## name = filename[:-6].replace(SLASH, DOT) + ## + ## if name[:len(package)] != package: + ## continue + ## self.zipfile.putNextEntry(ZipEntry(filename)) + ## copy(zf.getInputStream(entry), self.zipfile) + ## zf.close() + ## + ## def addDirectoryPackage(self, package, directory, skiplist): + ## for file in os.listdir(directory): + ## if file[-6:] != '.class': + ## continue + ## name = package+file[:-6] + ## if name in skiplist: + ## continue + ## entryname = SLASH.join(name.split('.')) + '.class' + ## self.zipfile.putNextEntry(ZipEntry(entryname)) + ## instream = FileInputStream(os.path.join(directory, file)) + ## copy(instream, self.zipfile) + ## instream.close() Index: javac.py =================================================================== RCS file: /cvsroot/jython/jython/Tools/jythonc/javac.py,v retrieving revision 2.10 retrieving revision 2.11 diff -C2 -r2.10 -r2.11 *** javac.py 2000/11/10 15:10:12 2.10 --- javac.py 2000/11/17 12:44:21 2.11 *************** *** 33,36 **** --- 33,37 ---- + import sys def compile(files, javac=None, cpathopt="-classpath", cpath=None, options=None, sourcedir=None): *************** *** 55,67 **** options = [] cmd.extend(options) # Classpath: # 1. python.jythonc.classpath property # 2. java.class.path property if cpath is None: ! cpath = sys.registry.getProperty("python.jythonc.classpath") ! if cpath is None: ! cpath = getClasspath() ! if sourcedir: ! cpath = cpath + java.io.File.pathSeparator + sourcedir cmd.extend([cpathopt, cpath]) cmd.extend(files) --- 56,81 ---- options = [] cmd.extend(options) + # new: # Classpath: # 1. python.jythonc.classpath property + # + # 2. java.class.path property + # + + # 3. sourcedir + # + + # 4. sys.path if cpath is None: ! sep = java.io.File.pathSeparator ! cpath = [] ! part = sys.registry.getProperty("python.jythonc.classpath") ! if part != None: ! cpath.extend(part.split(sep)) ! part = getClasspath() ! if part != None: ! cpath.extend(part.split(sep)) ! if sourcedir: ! cpath.append(sourcedir) ! cpath.extend(sys.path) ! cpath = sep.join(cpath) cmd.extend([cpathopt, cpath]) cmd.extend(files) Index: main.py =================================================================== RCS file: /cvsroot/jython/jython/Tools/jythonc/main.py,v retrieving revision 2.11 retrieving revision 2.12 diff -C2 -r2.11 -r2.12 *** main.py 2000/10/13 18:54:36 2.11 --- main.py 2000/11/17 12:44:21 2.12 *************** *** 168,174 **** def addCore(extraPackages): ! skiplist = ['org.python.core.parser', ! 'org.python.core.BytecodeLoader', ! 'org.python.core.jpython', ] extraPackages.append(('org.python.core', skiplist)) --- 168,173 ---- def addCore(extraPackages): ! skiplist = [ 'org.python.core.parser', ! #'org.python.core.BytecodeLoader', ] extraPackages.append(('org.python.core', skiplist)) Index: util.py =================================================================== RCS file: /cvsroot/jython/jython/Tools/jythonc/util.py,v retrieving revision 2.1 retrieving revision 2.2 diff -C2 -r2.1 -r2.2 *** util.py 2000/10/13 18:51:30 2.1 --- util.py 2000/11/17 12:44:21 2.2 *************** *** 25,26 **** --- 25,60 ---- zf.close() zipfiles.clear() + + # "tentative" + + import sys + import string + + from org.python.core import imp,Py + + from yapm import YaPM + + def findClass(c): + return Py.findClassEx(c) + + def reportPublicPlainClasses(jpkg): + classes = sys.packageManager.doDir(jpkg,0,1) + classes.remove('__name__') + return string.join(classes,',') + + def openResource(res): + return imp.getSyspathJavaLoader().getResourceAsStream(res) + + _ypm = None + + def listAllClasses(jpkg): + global _ypm + classes = sys.packageManager.doDir(jpkg,0,1) + classes.remove('__name__') + if _ypm is None: + _ypm = YaPM(sys.registry) + pkg2 = _ypm.lookupName(jpkg.__name__) + classes2 = _ypm.doDir(pkg2,0,1) + classes2.remove('__name__') + classes.extend(classes2) + return classes |
From: Samuele P. <ped...@us...> - 2000-11-17 12:41:13
|
Update of /cvsroot/jython/jython/org/python/core In directory slayer.i.sourceforge.net:/tmp/cvs-serv1809/core Added Files: CachedJarsPackageManager.java PathPackageManager.java SysPackageManager.java Removed Files: PyJavaDirPackage.java Log Message: Loading logic fixes: additions and deletions. For issues involved see the jython-dev list archives. --- NEW FILE --- package org.python.core; import java.util.Hashtable; import java.util.Vector; import java.util.Enumeration; import java.util.zip.ZipInputStream; import java.util.zip.ZipEntry; import java.io.*; import java.net.URL; import java.net.URLConnection; import java.net.URLDecoder; import java.lang.reflect.Modifier; /** Abstract package manager that gathers info about statically known classes * from a set of jars. This info can be eventually cached. * Off-the-shelf this class offers a local file-system based cache impl. */ public abstract class CachedJarsPackageManager extends PackageManager { /** Message log method - hook. This default impl does nothing. * @param msg message text */ protected void message(String msg) { } /** Warning log method - hook. This default impl does nothing. * @param warn warning text */ protected void warning(String warn) { } /** Comment log method - hook. This default impl does nothing. * @param msg message text */ protected void comment(String msg) { } /** Debug log method - hook. This default impl does nothing. * @param msg message text */ protected void debug(String msg) { } /** Filter class/pkg by name helper method - hook. * The default impl. is used by {@link #addJarToPackages} in order to filter out classes * whose name contains '$' (e.g. inner classes,...). * Should be used or overriden by derived classes too. Also to be used in {@link #doDir}. * @param name class/pkg name * @param pkg if true, name refers to a pkg * @return true if name must be filtered out */ protected boolean filterByName(String name,boolean pkg) { return name.indexOf('$') != -1; } /** Filter class by access perms helper method - hook. * The default impl. is used by {@link #addJarToPackages} in order to filter out non-public classes. * Should be used or overriden by derived classes too. Also to be used in {@link #doDir}. * Access perms can be read with {@link #checkAccess}. * @param name class name * @param acc class access permissions as int * @return true if name must be filtered out */ protected boolean filterByAccess(String name,int acc) { return (acc & Modifier.PUBLIC) != Modifier.PUBLIC; } private boolean indexModified; private Hashtable jarfiles; private static String vectorToString(Vector vec) { int n = vec.size(); StringBuffer ret = new StringBuffer(); for(int i=0; i<n; i++) { ret.append((String)vec.elementAt(i)); if (i<n-1) ret.append(","); } return ret.toString(); } // Add a single class from zipFile to zipPackages // Only add valid, public classes private void addZipEntry(Hashtable zipPackages, ZipEntry entry,ZipInputStream zip) throws IOException { String name = entry.getName(); //System.err.println("entry: "+name); if (!name.endsWith(".class")) return; char sep = '/'; int breakPoint = name.lastIndexOf(sep); if (breakPoint == -1) { breakPoint = name.lastIndexOf('\\'); sep = '\\'; } String packageName; if (breakPoint == -1) { packageName = ""; } else { packageName = name.substring(0,breakPoint).replace(sep, '.'); } String className = name.substring(breakPoint+1, name.length()-6); if (filterByName(className,false)) return; // An extra careful test, maybe should be ignored???? int access = checkAccess(zip); if ((access == -1) || filterByAccess(name,access)) return; Vector vec = (Vector)zipPackages.get(packageName); if (vec == null) { vec = new Vector(); zipPackages.put(packageName, vec); } vec.addElement(className); } // Extract all of the packages in a single jarfile private Hashtable getZipPackages(InputStream jarin) throws IOException { Hashtable zipPackages = new Hashtable(); ZipInputStream zip=new ZipInputStream(jarin); ZipEntry entry; while ((entry = zip.getNextEntry()) != null) { addZipEntry(zipPackages, entry, zip); zip.closeEntry(); } // Turn each vector into a comma-separated String for (Enumeration e = zipPackages.keys() ; e.hasMoreElements() ;) { Object key = e.nextElement(); Vector vec = (Vector)zipPackages.get(key); zipPackages.put(key, vectorToString(vec)); } return zipPackages; } /** Gathers classes info from jar specified by jarurl URL. * Eventually just using previously cached info. * Eventually updated info is not cached. * Persistent cache storage access goes through {@link #inOpenCacheFile}, {@link #outCreateCacheFile}. */ public void addJarToPackages(java.net.URL jarurl) { addJarToPackages(jarurl,null,false); } /** Gathers classes info from jar specified by jarurl URL. * Eventually just using previously cached info. * Eventually updated info is (re-)cached if param cache is true. * Persistent cache storage access goes through {@link #inOpenCacheFile}, {@link #outCreateCacheFile}. */ public void addJarToPackages(URL jarurl,boolean cache) { addJarToPackages(jarurl,null,cache); } /** Gathers classes info from jar specified by File jarfile. * Eventually just using previously cached info. * Eventually updated info is not cached. * Persistent cache storage access goes through {@link #inOpenCacheFile}, {@link #outCreateCacheFile}. */ public void addJarToPackages(File jarfile) { addJarToPackages(null,jarfile,false); } /** Gathers classes info from jar specified by File jarfile. * Eventually just using previously cached info. * Eventually updated info is (re-)cached if param cache is true. * Persistent cache storage access goes through {@link #inOpenCacheFile}, {@link #outCreateCacheFile}. */ public void addJarToPackages(File jarfile,boolean cache) { addJarToPackages(null,jarfile,cache); } private void addJarToPackages(URL jarurl,File jarfile,boolean cache) { try { boolean caching = jarfiles!=null; URLConnection jarconn = null; boolean localfile = true; if (jarfile == null) { jarconn = jarurl.openConnection(); // This is necessary because 'file:' url-connections // return always 0 through getLastModified (bug?). // And in order to handle localfiles (from urls too) uniformly. if(jarconn.getURL().getProtocol().equals("file")) { // ??pending: need to use java2 URLDecoder.decode? // but under 1.1 this is absent and should be simulated. jarfile = new File(jarurl.getPath().replace('/',File.separatorChar)); } else localfile = false; } if (localfile && !jarfile.exists()) return; Hashtable zipPackages = null; long mtime = 0; String jarcanon = null; JarXEntry entry = null; boolean brandNew = false; if(caching) { if(localfile) { mtime = jarfile.lastModified(); jarcanon = jarfile.getCanonicalPath(); } else { mtime = jarconn.getLastModified(); jarcanon = jarurl.toString(); } entry = (JarXEntry)jarfiles.get(jarcanon); if (entry == null) { message("processing new jar, '"+ jarcanon+"'"); String jarname; if(localfile) { jarname = jarfile.getName(); } else { jarname = jarurl.getPath(); int slash = jarname.lastIndexOf('/'); if (slash != -1) jarname=jarname.substring(slash+1); } jarname=jarname.substring(0,jarname.length()-4); entry = new JarXEntry(jarname); jarfiles.put(jarcanon, entry); brandNew = true; } if (mtime != 0 && entry.mtime == mtime) { zipPackages = readCacheFile(entry, jarcanon); } } if (zipPackages == null) { caching = caching && cache; if(caching) { indexModified = true; if (entry.mtime != 0) { message("processing modified jar, '"+ jarcanon+"'"); } entry.mtime = mtime; } InputStream jarin; if (jarconn == null) jarin = new BufferedInputStream(new FileInputStream(jarfile)); else jarin = jarconn.getInputStream(); zipPackages = getZipPackages(jarin); if(caching) writeCacheFile(entry, jarcanon, zipPackages, brandNew); // Write the cache file } addPackages(zipPackages, jarcanon); } catch (IOException ioe) { // silently skip any bad directories warning("skipping bad jar, '" + jarurl.toString() + "'"); } } private void addPackages(Hashtable zipPackages, String jarfile) { for (Enumeration e = zipPackages.keys() ; e.hasMoreElements() ;) { String pkg = (String)e.nextElement(); String classes = (String)zipPackages.get(pkg); makeJavaPackage(pkg, classes, jarfile); } } // Read in cache file storing package info for a single .jar // Return null and delete this cachefile if it is invalid private Hashtable readCacheFile(JarXEntry entry,String jarcanon) { String cachefile = entry.cachefile; long mtime = entry.mtime; debug("reading cache, '"+jarcanon+"'"); try { DataInputStream istream = inOpenCacheFile(cachefile); String old_jarcanon = istream.readUTF(); long old_mtime = istream.readLong(); if ((!old_jarcanon.equals(jarcanon)) || (old_mtime != mtime)) { comment("invalid cache file: "+ cachefile+", "+jarcanon+":"+ old_jarcanon+", "+mtime+":"+old_mtime); deleteCacheFile(cachefile); return null; } Hashtable packs = new Hashtable(); try { while (true) { String packageName = istream.readUTF(); String classes = istream.readUTF(); packs.put(packageName, classes); } } catch (EOFException eof) { ; } istream.close(); return packs; } catch (IOException ioe) { // if (cachefile.exists()) cachefile.delete(); return null; } } // Write a cache file storing package info for a single .jar private void writeCacheFile(JarXEntry entry,String jarcanon, Hashtable zipPackages,boolean brandNew) { try { DataOutputStream ostream = outCreateCacheFile(entry, brandNew); ostream.writeUTF(jarcanon); ostream.writeLong(entry.mtime); comment("rewriting cachefile for '"+jarcanon+"'"); for (Enumeration e = zipPackages.keys() ; e.hasMoreElements() ;) { String packageName = (String)e.nextElement(); String classes = (String)zipPackages.get(packageName); ostream.writeUTF(packageName); ostream.writeUTF(classes); } ostream.close(); } catch (IOException ioe) { warning("can't write cache file for '"+jarcanon+"'"); } } /** Initializes cache. Eventually reads back cache index. * Index persistent storage is accessed through {@link #inOpenIndex}. */ protected void initCache() { indexModified = false; jarfiles = new Hashtable(); try { DataInputStream istream = inOpenIndex(); if (istream == null) return; try { while (true) { String jarcanon = istream.readUTF(); String cachefile = istream.readUTF(); long mtime = istream.readLong(); jarfiles.put(jarcanon, new JarXEntry(cachefile,mtime)); } } catch (EOFException eof) { ; } istream.close(); } catch (IOException ioe) { warning("invalid index file"); } } /** Write back cache index. * Index persistent storage is accessed through {@link #outOpenIndex}. */ public void saveCache() { if(jarfiles == null || !indexModified ) return; indexModified = false; comment("writing modified index file"); try { DataOutputStream ostream = outOpenIndex(); for (Enumeration e = jarfiles.keys(); e.hasMoreElements();) { String jarcanon = (String)e.nextElement(); JarXEntry entry = (JarXEntry)jarfiles.get(jarcanon); ostream.writeUTF(jarcanon); ostream.writeUTF(entry.cachefile); ostream.writeLong(entry.mtime); } ostream.close(); } catch (IOException ioe) { warning("can't write index file"); } } // hooks for changing cache storage /** To pass a cachefile id by ref. And for internal use. * @see #outCreateCacheFile */ public static class JarXEntry extends Object { /** cachefile id */ public String cachefile; public long mtime; public JarXEntry(String cachefile) { this.cachefile = cachefile; } public JarXEntry(String cachefile,long mtime) { this.cachefile = cachefile; this.mtime = mtime; } } /** Open cache index for reading from persistent storage - hook. * Must Return null if this is absent. * This default impl is part of the off-the-shelf local file-system cache impl. * Can be overriden. */ protected DataInputStream inOpenIndex() throws IOException { File indexFile = new File(cachedir, "packages.idx"); if (!indexFile.exists()) return null; DataInputStream istream = new DataInputStream( new BufferedInputStream(new FileInputStream(indexFile))); return istream; } /** Open cache index for writing back to persistent storage - hook. * This default impl is part of the off-the-shelf local file-system cache impl. * Can be overriden. */ protected DataOutputStream outOpenIndex() throws IOException { File indexFile = new File(cachedir, "packages.idx"); return new DataOutputStream( new BufferedOutputStream(new FileOutputStream(indexFile))); } /** Open cache file for reading from persistent storage - hook. * This default impl is part of the off-the-shelf local file-system cache impl. * Can be overriden. */ protected DataInputStream inOpenCacheFile(String cachefile) throws IOException { return new DataInputStream(new BufferedInputStream(new FileInputStream(cachefile))); } /** Delete (invalidated) cache file from persistent storage - hook. * This default impl is part of the off-the-shelf local file-system cache impl. * Can be overriden. */ protected void deleteCacheFile(String cachefile) { new File(cachefile).delete(); } /** Create/open cache file for rewriting back to persistent storage - hook. * If create is false, cache file is supposed to exist and must be opened * for rewriting, entry.cachefile is a valid cachefile id. * If create is true, cache file must be created. entry.cachefile is a flat * jarname to be used to produce a valid cachefile id (to be put back in entry.cachefile * on exit). * This default impl is part of the off-the-shelf local file-system cache impl. * Can be overriden. */ protected DataOutputStream outCreateCacheFile(JarXEntry entry, boolean create) throws IOException { File cachefile = null; if(create) { int index = 1; String suffix = ""; String jarname = entry.cachefile; while (true) { cachefile = new File(cachedir, jarname+suffix+".pkc"); //System.err.println("try cachefile: "+cachefile); if (!cachefile.exists()) break; suffix = "$"+index; index += 1; } entry.cachefile = cachefile.getCanonicalPath(); } else cachefile = new File(entry.cachefile); return new DataOutputStream(new BufferedOutputStream(new FileOutputStream(cachefile))); } // for default cache (local fs based) impl private File cachedir; /** Initialize off-the-shelf (default) local file-system cache impl. * Must be called before {@link #initCache}. * cachedir is the cache repository directory, this is eventually created. * Returns true if dir works. */ protected boolean useCacheDir(File cachedir) { if(cachedir == null) return false; if (!cachedir.isDirectory() && cachedir.mkdirs() == false) { warning("can't create package cache dir, '"+cachedir+"'"); return false; } this.cachedir = cachedir; return true; } } --- NEW FILE --- package org.python.core; import java.io.*; import java.lang.reflect.Modifier; /** Path package manager. Gathering classes info dynamically from a set of directories * in path {@link #searchPath}, and statically from a set of jars, like {@link CachedJarsPackageManager}. */ public abstract class PathPackageManager extends CachedJarsPackageManager { public PyList searchPath; public PathPackageManager() { searchPath = new PyList(); } /** Helper for {@link #packageExists(java.lang.String,java.lang.String)}. * Scans for package pkg.name the directories in path. * */ protected boolean packageExists(PyList path,String pkg,String name) { String child = pkg.replace('.',File.separatorChar) + File.separator + name; for (int i=0; i < path.__len__(); i++) { String dir = path.get(i).__str__().toString(); if(dir.length() == 0) dir = null; if (new File(dir,child).isDirectory()) return true; } return false; } /** Helper for {@link #doDir(PyJavaPackage,boolean,boolean)}. * Scans for package jpkg content over the directories in path. * Add to ret the founded classes/pkgs. * Filter out classes using {@link #filterByName},{@link #filterByAccess}. */ protected void doDir(PyList path,PyList ret, PyJavaPackage jpkg,boolean instantiate,boolean exclpkgs) { String child=jpkg.__name__.replace('.',File.separatorChar); for (int i=0; i < path.__len__(); i++) { String dir = path.get(i).__str__().toString(); if(dir.length() == 0) dir = null; File childFile = new File(dir,child); String[] list=childFile.list(); if(list == null) continue; doList: for (int j=0; j < list.length; j++) { String jname = list[j]; File cand = new File(childFile, jname); int jlen = jname.length(); boolean pkgCand=false; if (cand.isDirectory()) { if (!instantiate && exclpkgs) continue; pkgCand = true; } else { if(!jname.endsWith(".class")) continue; jlen-=6; } jname = jname.substring(0,jlen); PyString name = new PyString(jname); if (filterByName(jname,pkgCand)) continue; // for opt maybe we should some hash-set for ret if (jpkg.__dict__.has_key(name) || jpkg.clsSet.has_key(name) || ret.__contains__(name)) { continue; } if(!Character.isJavaIdentifierStart(jname.charAt(0))) continue; for(int k = 1; k < jlen; k++) { if(!Character.isJavaIdentifierPart(jname.charAt(k))) continue doList; } if(!pkgCand) { try { int acc = checkAccess(new BufferedInputStream(new FileInputStream(cand))); if ((acc == -1) || filterByAccess(jname, acc) ) continue; } catch(IOException e) { continue; } } if(instantiate) { if(pkgCand) jpkg.addPackage(jname); else jpkg.addLazyClass(jname); } ret.append(name); } } } /** Add directory dir (if exists) to {@link #searchPath}. */ public void addDirectory(File dir) { try { if (dir.getPath().length() == 0) searchPath.append(Py.EmptyString); else searchPath.append(new PyString(dir.getCanonicalPath())); } catch(IOException e) { warning("skipping bad directory, '" +dir+ "'"); } } // ??pending: // Uses simply split and not a StringTokenizer+trim to adhere to sun jvm parsing of classpath. // E.g. "a;" is parsed by sun jvm as a, ""; the latter is interpreted as cwd. // jview trims and cwd is per default in classpath. The logic here should work // for both(...). Need to distinguish? // This code does not avoid duplicates in searchPath. Should cause no problem (?). /** Adds "classpath" entry. Calls {@link #addDirectory} if path refers to a dir, {@link #addJarToPackages(java.io.File, boolean)} with param cache true if path refers to a jar. */ public void addClassPath(String path) { PyList paths = new PyString(path).split(java.io.File.pathSeparator); for (int i = 0; i < paths.__len__(); i++) { String entry = paths.get(i).toString(); if (entry.endsWith(".jar") || entry.endsWith(".zip")) { addJarToPackages(new File(entry),true); } else { File dir = new File(entry); if (entry.length() == 0 || dir.isDirectory()) addDirectory(dir); } } } public PyList doDir(PyJavaPackage jpkg,boolean instantiate,boolean exclpkgs) { PyList basic = basicDoDir(jpkg,instantiate,exclpkgs); PyList ret = new PyList(); doDir(searchPath,ret,jpkg,instantiate,exclpkgs); return merge(basic,ret); } public boolean packageExists(String pkg,String name) { return packageExists(searchPath,pkg,name); } } --- NEW FILE --- package org.python.core; import java.util.Properties; import java.util.StringTokenizer; import java.io.*; /** System package manager. * Used by org.python.core.PySystemState. */ public class SysPackageManager extends PathPackageManager { protected void message(String msg) { Py.writeMessage("*sys-package-mgr*",msg); } protected void warning(String warn) { Py.writeWarning("*sys-package-mgr*",warn); } protected void comment(String msg) { Py.writeComment("*sys-package-mgr*",msg); } protected void debug(String msg) {Py.writeDebug("*sys-package-mgr*",msg); } public SysPackageManager(File cachedir, Properties registry) { if(useCacheDir(cachedir)) { initCache(); findAllPackages(registry); saveCache(); } } private void addJarDir(String jdir) { File file = new File(jdir); if (!file.isDirectory()) return; String[] files = file.list(); for(int i=0; i<files.length; i++) { String entry = files[i]; if (entry.endsWith(".jar") || entry.endsWith(".zip")) { addJarToPackages(new File(jdir,entry),true); } } } private void addJarPath(String path) { StringTokenizer tok = new StringTokenizer(path, java.io.File.pathSeparator); while (tok.hasMoreTokens()) { // ??pending: do jvms trim? how is interpreted entry=""? String entry = tok.nextToken(); addJarDir(entry); } } private void findAllPackages(Properties registry) { String paths = registry.getProperty( "python.packages.paths", "java.class.path,sun.boot.class.path"); String directories = registry.getProperty( "python.packages.directories", "java.ext.dirs"); String fakepath = registry.getProperty("python.packages.fakepath", null); StringTokenizer tok = new StringTokenizer(paths, ","); while (tok.hasMoreTokens()) { String entry = tok.nextToken().trim(); String tmp = registry.getProperty(entry); if (tmp == null) continue; addClassPath(tmp); } tok = new StringTokenizer(directories, ","); while (tok.hasMoreTokens()) { String entry = tok.nextToken().trim(); String tmp = registry.getProperty(entry); if (tmp == null) continue; addJarPath(tmp); } if (fakepath != null) addClassPath(fakepath); } public Class findClass(String pkg,String name) { Class c; if (pkg.length()>0) c = Py.findClassEx(pkg+'.'+name); else c = Py.findClassEx(name); return c; } public PyList doDir(PyJavaPackage jpkg,boolean instantiate,boolean exclpkgs) { PyList basic = basicDoDir(jpkg,instantiate,exclpkgs); PyList ret = new PyList(); doDir(searchPath,ret,jpkg,instantiate,exclpkgs); PySystemState system = Py.getSystemState(); if (system.getClassLoader() == null) doDir(system.path,ret,jpkg,instantiate,exclpkgs); return merge(basic,ret); } public boolean packageExists(String pkg,String name) { if (packageExists(searchPath,pkg,name)) return true; PySystemState system = Py.getSystemState(); if (system.getClassLoader() == null && packageExists(Py.getSystemState().path,pkg,name)) { return true; } return false; } } --- PyJavaDirPackage.java DELETED --- |
Update of /cvsroot/jython/jython/org/python/core In directory slayer.i.sourceforge.net:/tmp/cvs-serv1091/core Modified Files: BytecodeLoader.java PackageManager.java Py.java PyJavaClass.java PyJavaPackage.java PyModule.java PySystemState.java imp.java Log Message: Loading logic fixes. For issues involved see the jython-dev list archives. Index: BytecodeLoader.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/BytecodeLoader.java,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -r2.6 -r2.7 *** BytecodeLoader.java 1999/10/28 17:47:41 2.6 --- BytecodeLoader.java 2000/11/17 12:32:43 2.7 *************** *** 8,11 **** --- 8,44 ---- public class BytecodeLoader extends ClassLoader { + + public InputStream getResourceAsStream(String res) { + ClassLoader classLoader = Py.getSystemState().getClassLoader(); + if (classLoader != null) return classLoader.getResourceAsStream(res); + + classLoader = this.getClass().getClassLoader(); + + InputStream ret; + + if (classLoader != null) ret = classLoader.getResourceAsStream(res); + else ret = ClassLoader.getSystemResourceAsStream(res); + + if (ret != null) return ret; + + if(res.charAt(0) == '/') res = res.substring(1); + + res.replace('/',File.separatorChar); + + PyList path = Py.getSystemState().path; + for (int i=0; i < path.__len__(); i++) { + String dir = path.get(i).__str__().toString(); + if (dir.length() == 0) dir = null; + try { + return new BufferedInputStream(new FileInputStream(new File(dir,res))); + } + catch (IOException e) { + continue; + } + } + + return null; + } + // override from abstract base class protected Class loadClass(String name, boolean resolve) *************** *** 20,29 **** // Search the sys.path for a .class file matching the named class. // TBD: This registry option is temporary. ! if (Options.extendedClassLoader && // KLUDGE ALERT: without this test, running jpython // interactively from the build directory will fail with // ClassCircularityError or LinkageError. There's gotta be a // better way. ! !name.startsWith("org.python")) { PyList path = Py.getSystemState().path; --- 53,70 ---- // Search the sys.path for a .class file matching the named class. // TBD: This registry option is temporary. ! try { ! return Class.forName(name); ! } ! catch(ClassNotFoundException e) { ! } ! ! /* previously: if ! Options.extendedClassLoader && // KLUDGE ALERT: without this test, running jpython // interactively from the build directory will fail with // ClassCircularityError or LinkageError. There's gotta be a // better way. ! !name.startsWith("org.python") ! */ { PyList path = Py.getSystemState().path; *************** *** 45,51 **** } } ! // couldn't find the .class file on sys.path, so give the system ! // class loader the final shot at it ! return findSystemClass(name); } --- 86,92 ---- } } ! ! // couldn't find the .class file on sys.path ! throw new ClassNotFoundException(name); } *************** *** 63,68 **** } try { ! if (dir == "") ! dir = "."; return new FileInputStream(new File(dir, accum+".class")); } --- 104,109 ---- } try { ! if (dir.length() == 0) ! dir = null; return new FileInputStream(new File(dir, accum+".class")); } Index: PackageManager.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PackageManager.java,v retrieving revision 2.2 retrieving revision 2.3 diff -C2 -r2.2 -r2.3 *** PackageManager.java 1999/05/17 19:59:37 2.2 --- PackageManager.java 2000/11/17 12:32:43 2.3 *************** *** 1,91 **** - // Copyright © Corporation for National Research Initiatives - package org.python.core; - - import java.util.*; - import java.io.*; - import java.util.zip.*; - - class JarEntry implements Serializable { - public long mtime; - public File cachefile; - public JarEntry(File cachefile, long mtime) { - this.mtime = mtime; - this.cachefile = cachefile; - } - public String toString() { - return "JarEntry("+cachefile+":"+mtime+")"; - } - } ! class JarPackage { ! public String name; ! public String classes; ! public String filename; ! public JarPackage(String name, String classes, String filename) { ! this.name = name; ! this.classes = classes; ! this.filename = filename; ! } ! } ! ! public class PackageManager { ! public File cachedir; ! private boolean indexModified; ! public Hashtable jarfiles; ! public Hashtable packages; ! public PyStringMap topLevelPackages; ! public PyList searchPath; ! public PyObject topDirectoryPackage; ! public PackageManager(File cachedir, Properties registry) { ! searchPath = new PyList(); ! packages = new Hashtable(); ! topLevelPackages = new PyStringMap(); ! topDirectoryPackage = new PyJavaDirPackage("", searchPath); ! this.cachedir = cachedir; ! initPackages(registry); } ! public void initPackages(Properties registry) { ! if (cachedir == null) return; ! ! if (!cachedir.isDirectory() && cachedir.mkdirs() == false) { ! Py.writeWarning("packageManager", ! "can't create package cache dir, '"+cachedir+"'"); ! return; ! } ! ! loadIndexFile(); ! findAllPackages(registry); ! saveIndexFile(); ! ! Hashtable packs = packages; ! ! for (Enumeration e = packs.elements(); e.hasMoreElements(); ) { ! JarPackage jp = (JarPackage)e.nextElement(); ! makeJavaPackage(jp.name, jp.classes, jp.filename); } } ! public PyObject lookupName(String name) { ! int dot = name.indexOf('.'); ! String firstName=name; ! String lastName=null; ! if (dot != -1) { ! firstName = name.substring(0,dot); ! lastName = name.substring(dot+1, name.length()); ! } ! firstName = firstName.intern(); ! PyObject top = findName(firstName); ! if (top == null) return null; ! name = lastName; ! while (name != null) { ! dot = lastName.indexOf('.'); ! firstName = name; ! lastName = null; if (dot != -1) { firstName = name.substring(0,dot); --- 1,84 ---- ! package org.python.core; ! /** Abstract package manager. ! */ ! public abstract class PackageManager extends Object { ! ! public PyJavaPackage topLevelPackage; ! ! public PackageManager() { ! topLevelPackage = new PyJavaPackage("",this); ! } ! ! abstract public Class findClass(String pkg,String name); ! ! /** Dynamically check if pkg.name exists as java pkg in the controlled hierarchy. ! * Should be overriden. ! * @param pkg parent pkg name ! * @param name candidate name ! * @return true if pkg exists ! */ ! public abstract boolean packageExists(String pkg,String name); ! ! /** Reports the specified package content names. Should be overriden. ! * Used by {@link PyJavaPackage#__dir__} and {@link PyJavaPackage#fillDir}. ! * @return resulting list of names (PyList of PyString) ! * @param jpkg queried package ! * @param instantiate if true then instatiate reported names in package dict ! * @param exclpkgs exclude packages (just when instantiate is false) ! */ ! public abstract PyList doDir(PyJavaPackage jpkg,boolean instantiate,boolean exclpkgs); ! ! /** Basic helper implementation of {@link #doDir}. ! * It merges information from jpkg {@link PyJavaPackage#clsSet} and {@link PyJavaPackage#__dict__}. ! */ ! protected PyList basicDoDir(PyJavaPackage jpkg,boolean instantiate,boolean exclpkgs) { ! PyStringMap dict = jpkg.__dict__; ! PyStringMap cls = jpkg.clsSet; ! ! if(!instantiate) { ! PyList ret = cls.keys(); ! ! PyList dictKeys = dict.keys(); ! ! for(int i=0; i < dictKeys.__len__(); i++) { ! PyObject name = dictKeys.get(i); ! if (!cls.has_key(name)) { ! if (exclpkgs && dict.get(name) instanceof PyJavaPackage) continue; ! ret.append(name); ! } ! } ! return ret; ! } ! PyList clsNames = cls.keys(); ! for(int i=0; i < clsNames.__len__(); i++) { ! PyObject name = clsNames.get(i); ! if(!dict.has_key(name)) jpkg.addLazyClass(name.toString()); ! } ! return dict.keys(); } ! /** Helper merging list2 into list1. Returns list1. ! */ ! protected PyList merge(PyList list1,PyList list2) { ! for(int i=0; i < list2.__len__() ;i++) { ! PyObject name = list2.get(i); ! list1.append(name); } + + return list1; } ! public PyObject lookupName(String name) { ! PyObject top = topLevelPackage; ! do { ! int dot = name.indexOf('.'); ! String firstName = name; ! String lastName = null; if (dot != -1) { firstName = name.substring(0,dot); *************** *** 95,132 **** top = top.__findattr__(firstName); if (top == null) return null; name = lastName; ! } return top; } - ! public PyObject jarFindName(String name) { ! return topLevelPackages.__finditem__(name); ! } ! ! public PyObject dirFindName(String name) { ! return topDirectoryPackage.__findattr__(name); ! } ! ! /** ! Find a top-level package by name (a top-level package is one without ! any '.' in its name). ! ! @param name the name of the top-level package to find - ! <b> must be an interned string </b>. ! @return a package object or null if name is not found. ! **/ ! public PyObject findName(String name) { ! // First look for this as a top-level .jar package ! PyObject pkg = jarFindName(name); ! if (pkg != null) return pkg; ! // Then check for it in the directory packages (this is slower) ! return dirFindName(name); } - // Check that a given stream is a valid Java .class file - // And return its access permissions as an int - static int checkAccess(DataInputStream istream) throws IOException { int magic = istream.readInt(); int minor = istream.readShort(); --- 88,122 ---- top = top.__findattr__(firstName); if (top == null) return null; + // ??pending: test for jpkg/jclass? name = lastName; ! } while (name != null); return top; } ! /** Creates package/updates statically known classes info. ! * Uses {@link PyJavaPackage#addPackage(java.lang.String, java.lang.String) }, {@link PyJavaPackage#addPlaceholders}. ! * ! * @param name package name ! * @param classes comma-separated string ! * @param jarfile involved jarfile; can be null ! * @return created/updated package ! */ ! public PyJavaPackage makeJavaPackage(String name,String classes,String jarfile) { ! PyJavaPackage p = topLevelPackage; ! if(name.length() != 0) p=p.addPackage(name,jarfile); ! if (classes != null) p.addPlaceholders(classes); ! ! return p; } + + private static final int MAXSKIP = 512; + + /** Check that a given stream is a valid Java .class file. + * And return its access permissions as an int. + */ + static protected int checkAccess(java.io.InputStream cstream) throws java.io.IOException { + java.io.DataInputStream istream=new java.io.DataInputStream(cstream); int magic = istream.readInt(); int minor = istream.readShort(); *************** *** 140,159 **** //System.out.println(""+i+" : "+cid); switch (cid) { ! case 7: istream.skipBytes(2); break; ! case 9: ! case 10: ! case 11: istream.skipBytes(4); break; ! case 8: istream.skipBytes(2); break; ! case 3: ! case 4: istream.skipBytes(4); break; ! case 5: ! case 6: istream.skipBytes(8); i++; break; ! case 12: istream.skipBytes(4); break; ! case 1: //System.out.println("utf: "+istream.readUTF()+";"); ! int slength = istream.readShort(); istream.skipBytes(slength); break; ! default: //System.err.println("unexpected cid: "+cid+", "+i+", "+nconstants); //for (int j=0; j<10; j++) { System.err.print(", "+istream.readByte()); } --- 130,153 ---- //System.out.println(""+i+" : "+cid); switch (cid) { ! case 7: istream.skipBytes(2); break; ! case 9: ! case 10: ! case 11: istream.skipBytes(4); break; ! case 8: istream.skipBytes(2); break; ! case 3: ! case 4: istream.skipBytes(4); break; ! case 5: ! case 6: istream.skipBytes(8); i++; break; ! case 12: istream.skipBytes(4); break; ! case 1: //System.out.println("utf: "+istream.readUTF()+";"); ! int slength = istream.readUnsignedShort(); ! while (slength > MAXSKIP) { // workaround to java1.1 bug ! istream.skipBytes(MAXSKIP); ! slength -= MAXSKIP; ! } istream.skipBytes(slength); break; ! default: //System.err.println("unexpected cid: "+cid+", "+i+", "+nconstants); //for (int j=0; j<10; j++) { System.err.print(", "+istream.readByte()); } *************** *** 165,540 **** } - // Add a single class from zipFile to zipPackages - // Only add valid, public classes - static void addZipEntry(Hashtable zipPackages, ZipEntry entry, - ZipFile zipFile) - throws IOException - { - String name = entry.getName(); - //System.err.println("entry: "+name); - if (!name.endsWith(".class")) return; - // Ignore inner classes (at least for now) - if (name.indexOf("$") != -1) return; - char sep = '/'; - int breakPoint = name.lastIndexOf(sep); - if (breakPoint == -1) { - breakPoint = name.lastIndexOf('\\'); - sep = '\\'; - // Ignore entries in top-level package - if (breakPoint == -1) return; - } - - String packageName = name.substring(0,breakPoint).replace(sep, '.'); - String className = name.substring(breakPoint+1, name.length()-6); - - // An extra careful test, maybe should be ignored???? - InputStream istream = zipFile.getInputStream(entry); - int access = checkAccess( - new DataInputStream(new BufferedInputStream(istream))); - if ((access == -1) || ((access & 0x01) != 1)) return; - - Vector vec = (Vector)zipPackages.get(packageName); - if (vec == null) { - vec = new Vector(); - zipPackages.put(packageName, vec); - } - vec.addElement(className); - } - - /*public static String[] vectorToStrings(Vector vec) { - int n = vec.size(); - String[] ret = new String[n]; - for(int i=0; i<n; i++) { - ret[i] = (String)vec.elementAt(i); - } - return ret; - }*/ - static String vectorToString(Vector vec) { - int n = vec.size(); - StringBuffer ret = new StringBuffer(); - for(int i=0; i<n; i++) { - ret.append((String)vec.elementAt(i)); - if (i<n-1) ret.append(","); - } - return ret.toString(); - } - - - // Extract all of the packages in a single jarfile - static Hashtable getZipPackages(File jarfile) throws IOException { - Hashtable zipPackages = new Hashtable(); - ZipFile zf = new ZipFile(jarfile); - for (Enumeration e = zf.entries() ; e.hasMoreElements() ;) { - ZipEntry entry = (ZipEntry)e.nextElement(); - addZipEntry(zipPackages, entry, zf); - } - // Turn each vector into a comma-separated String - for (Enumeration e = zipPackages.keys() ; e.hasMoreElements() ;) { - Object key = e.nextElement(); - Vector vec = (Vector)zipPackages.get(key); - zipPackages.put(key, vectorToString(vec)); - } - return zipPackages; - } - - - public void addDirectoryToPackages(File directory) { - try { - if (!directory.isDirectory()) return; - - searchPath.append(new PyString(directory.getCanonicalPath())); - } catch (IOException ioe) { - // silently skip any bad directories - Py.writeWarning("packageManager", - "skipping bad directory, '" + - directory.toString() + "'"); - } - } - - - public void addJarToPackages(File jarfile) { - try { - if (!jarfile.exists()) return; - - long mtime = jarfile.lastModified(); - String canonicalJarfile = jarfile.getCanonicalPath(); - JarEntry jarEntry = (JarEntry)jarfiles.get(canonicalJarfile); - - if (jarEntry == null) { - Py.writeMessage("packageManager", "processing new jar, \""+ - canonicalJarfile+"\""); - - jarEntry = new JarEntry(findJarCacheFile(jarfile), 0); - jarfiles.put(canonicalJarfile, jarEntry); - } - - Hashtable zipPackages = null; - if (jarEntry.mtime == mtime) { - zipPackages = readCacheFile(jarEntry.cachefile, mtime, - canonicalJarfile); - } - - if (zipPackages == null) { - indexModified = true; - if (jarEntry.mtime != 0) { - Py.writeMessage("packageManager", - "processing modified jar, \""+ - canonicalJarfile+"\""); - } - jarEntry.mtime = mtime; - - zipPackages = getZipPackages(jarfile); - // Write the cache file - writeCacheFile(jarEntry.cachefile, mtime, - canonicalJarfile, zipPackages); - } - - addPackages(zipPackages, canonicalJarfile); - } catch (IOException ioe) { - // silently skip any bad directories - Py.writeWarning("packageManager", - "skipping bad jarfile, '" + - jarfile.toString() + "'"); - } - } - - void addPackages(Hashtable zipPackages, String jarfile) { - for (Enumeration e = zipPackages.keys() ; e.hasMoreElements() ;) { - Object key = e.nextElement(); - JarPackage value = new JarPackage((String)key, - (String)zipPackages.get(key), - jarfile); - //Object value = zipPackages.get(key); - packages.put(key, value); - } - } - - - // Find a file in the current cachedir to hold cache for this jar - File findJarCacheFile(File jarfile) { - String jname = jarfile.getName(); - jname = jname.substring(0,jname.length()-4); - - int index = 1; - String suffix = ""; - File cachefile = null; - while (true) { - cachefile = new File(cachedir, jname+suffix+".pkc"); - //System.err.println("try cachefile: "+cachefile); - if (!cachefile.exists()) break; - suffix = "$"+index; - index += 1; - } - return cachefile; - } - - // Write a cache file storing package info for a single .jar - public static void writeCacheFile(File cachefile, long mtime, - String canonicalJarfile, - Hashtable zipPackages) - { - try { - DataOutputStream ostream = new DataOutputStream( - new BufferedOutputStream(new FileOutputStream(cachefile))); - ostream.writeUTF(canonicalJarfile); - ostream.writeLong(mtime); - Py.writeComment("packageManager", "rewriting cachefile for '"+ - canonicalJarfile+"'"); - - for (Enumeration e = zipPackages.keys() ; e.hasMoreElements() ;) { - String packageName = (String)e.nextElement(); - String classes = (String)zipPackages.get(packageName); - ostream.writeUTF(packageName); - ostream.writeUTF(classes); - } - ostream.close(); - } catch (IOException ioe) { - Py.writeWarning("packageManager", "can't write cache file to, '"+ - cachefile+"'"); - } - } - - // Read in cache file storing package info for a single .jar - // Return null and delete this cachefile if it is invalid - public static Hashtable readCacheFile(File cachefile, long mtime, - String canonicalJarfile) - { - Py.writeDebug("packageManager", "reading cache, '"+ - canonicalJarfile+"'"); - try { - DataInputStream istream = new DataInputStream( - new BufferedInputStream(new FileInputStream(cachefile))); - String old_jarfile = istream.readUTF(); - long old_mtime = istream.readLong(); - if ((!old_jarfile.equals(canonicalJarfile)) || - (old_mtime != mtime)) - { - Py.writeComment("packageManager", - "invalid cache file: "+ - cachefile+", "+canonicalJarfile+":"+ - old_jarfile+", "+mtime+":"+old_mtime); - cachefile.delete(); - return null; - } - Hashtable packs = new Hashtable(); - try { - while (true) { - String packageName = istream.readUTF(); - String classes = istream.readUTF(); - packs.put(packageName, classes); - } - } catch (EOFException eof) { - ; - } - istream.close(); - - return packs; - } catch (IOException ioe) { - if (cachefile.exists()) cachefile.delete(); - return null; - } - } - - - public void findAllPackages(Properties registry) { - String paths = registry.getProperty( - "python.packages.paths", - "java.class.path,sun.boot.class.path"); - String directories = registry.getProperty( - "python.packages.directories", - "java.ext.dirs"); - String fakepath = registry.getProperty("python.packages.fakepath", ""); - - StringTokenizer tok = new StringTokenizer(paths, ","); - while (tok.hasMoreTokens()) { - String entry = tok.nextToken().trim(); - String tmp = registry.getProperty(entry); - if (tmp == null) continue; - addClassPath(tmp); - } - - tok = new StringTokenizer(directories, ","); - while (tok.hasMoreTokens()) { - String entry = tok.nextToken().trim(); - String tmp = registry.getProperty(entry); - if (tmp == null) continue; - addJarPath(tmp); - } - - addClassPath(fakepath); - } - - - public PyJavaPackage makeJavaPackage(String name, String classes, - String jarfile) - { - int dot = name.indexOf('.'); - String firstName=name; - String lastName=null; - if (dot != -1) { - firstName = name.substring(0,dot); - lastName = name.substring(dot+1, name.length()); - } - - firstName = firstName.intern(); - PyJavaPackage p = - (PyJavaPackage)topLevelPackages.__finditem__(firstName); - if (p == null) { - p = new PyJavaPackage(firstName, jarfile); - topLevelPackages.__setitem__(firstName, p); - } - PyJavaPackage ret = p; - if (lastName != null) ret = p.addPackage(lastName, jarfile); - ret._unparsedAll = classes; - return ret; - } - - public void addJarDir(String jdir) { - File file = new File(jdir); - if (!file.isDirectory()) return; - String[] files = file.list(); - for(int i=0; i<files.length; i++) { - String entry = files[i]; - if (entry.endsWith(".jar") || entry.endsWith(".zip")) { - addJarToPackages(new File(jdir, entry)); - } - } - /*} catch (IOException ioe) { - Py.writeWarning("packageManager", "bad jar directory, '"+jdir+"'"); - }*/ - } - public void addJarPath(String path) { - StringTokenizer tok = - new StringTokenizer(path, java.io.File.pathSeparator); - while (tok.hasMoreTokens()) { - String entry = tok.nextToken(); - addJarDir(entry); - } - } - - public void addClassPath(String path) { - StringTokenizer tok = - new StringTokenizer(path, java.io.File.pathSeparator); - while (tok.hasMoreTokens()) { - String entry = tok.nextToken().trim(); - if (entry.endsWith(".jar") || entry.endsWith(".zip")) { - addJarToPackages(new File(entry)); - } else { - addDirectoryToPackages(new File(entry)); - } - } - } - - public void loadIndexFile() { - indexModified = false; - jarfiles = new Hashtable(); - File indexFile = new File(cachedir, "packages.idx"); - - try { - if (!indexFile.exists()) return; - - DataInputStream istream = new DataInputStream( - new BufferedInputStream(new FileInputStream(indexFile))); - try { - while (true) { - String jarfile = istream.readUTF(); - String cachefile = istream.readUTF(); - long mtime = istream.readLong(); - jarfiles.put(jarfile, new JarEntry(new File(cachefile), - mtime)); - } - } catch (EOFException eof) { - ; - } - istream.close(); - } catch (IOException ioe) { - Py.writeWarning("packageManager", - "invalid index file, '"+indexFile+"'"); - } - } - - public void saveIndexFile() { - if (!indexModified) return; - indexModified = false; - - Py.writeComment("packageManager", "writing modified index file"); - File indexFile = new File(cachedir, "packages.idx"); - - try { - DataOutputStream ostream = new DataOutputStream( - new BufferedOutputStream(new FileOutputStream(indexFile))); - for (Enumeration e = jarfiles.keys(); e.hasMoreElements();) { - String jarfile = (String)e.nextElement(); - JarEntry je = (JarEntry)jarfiles.get(jarfile); - ostream.writeUTF(jarfile); - ostream.writeUTF(je.cachefile.getCanonicalPath()); - ostream.writeLong(je.mtime); - } - ostream.close(); - } catch (IOException ioe) { - Py.writeWarning("packageManager", - "can't write index file, '"+indexFile+"'"); - } - } } --- 159,162 ---- Index: Py.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/Py.java,v retrieving revision 2.24 retrieving revision 2.25 diff -C2 -r2.24 -r2.25 *** Py.java 2000/11/07 18:44:20 2.24 --- Py.java 2000/11/17 12:32:43 2.25 *************** *** 10,13 **** --- 10,16 ---- static boolean frozen; static String frozenPackage=null; + private final static Object PRESENT=new Object(); + static java.util.Hashtable frozenModules; + static boolean initialized; *************** *** 260,270 **** } ! /** @deprecated **/ public static Object tojava(PyObject o, String s) { ! try { ! return tojava(o, Class.forName(s)); ! } catch (ClassNotFoundException exc) { ! throw Py.TypeError("can't convert to: "+s); ! } } --- 263,271 ---- } ! // ??pending: was @deprecated but is actually used by proxie code. Can get rid of it? public static Object tojava(PyObject o, String s) { ! Class c = findClass(s); ! if (c == null) throw Py.TypeError("can't convert to: "+s); ! return tojava(o, c); // prev:Class.forName } *************** *** 535,556 **** } public static Class findClass(String name) { try { ClassLoader classLoader = Py.getSystemState().getClassLoader(); ! if (classLoader == null) ! return Class.forName(name); ! else return classLoader.loadClass(name); } catch (ClassNotFoundException e) { ! // e.printStackTrace(); return null; } catch (IllegalArgumentException e) { ! // e.printStackTrace(); return null; } catch (NoClassDefFoundError e) { ! // e.printStackTrace(); return null; } --- 536,582 ---- } + + public static Class relFindClass(Class home,String name) { + try { + ClassLoader loader = home.getClassLoader(); + if (loader != null) return loader.loadClass(name); + else return Class.forName(name); + } catch (ClassNotFoundException exc) { + return null; + } catch (Throwable t) { + throw Py.JavaError(t); + } + } + + private static boolean secEnv=false; + public static Class findClass(String name) { try { ClassLoader classLoader = Py.getSystemState().getClassLoader(); ! if (classLoader != null) return classLoader.loadClass(name); ! ! if(!secEnv) { ! try { ! classLoader = imp.getSyspathJavaLoader(); ! } ! catch(SecurityException e) { ! secEnv=true; ! } return classLoader.loadClass(name); + } + + return Class.forName(name); + } catch (ClassNotFoundException e) { ! // e.printStackTrace(); return null; } catch (IllegalArgumentException e) { ! // e.printStackTrace(); return null; } catch (NoClassDefFoundError e) { ! // e.printStackTrace(); return null; } *************** *** 561,568 **** try { ClassLoader classLoader = Py.getSystemState().getClassLoader(); ! if (classLoader == null) ! return Class.forName(name); ! else ! return classLoader.loadClass(name); } catch (ClassNotFoundException e) { --- 587,603 ---- try { ClassLoader classLoader = Py.getSystemState().getClassLoader(); ! if (classLoader != null) return classLoader.loadClass(name); ! ! if(!secEnv) { ! try { ! classLoader = imp.getSyspathJavaLoader(); ! } ! catch(SecurityException e) { ! secEnv=true; ! } ! return classLoader.loadClass(name); ! } ! ! return Class.forName(name); } catch (ClassNotFoundException e) { *************** *** 621,632 **** } - /* if (modules != null) { ! System.out.println("modules: "); ! for (int i = 0; i < modules.length; i++) ! System.out.print(modules[i] + ", "); ! System.out.println(); } - */ if (packages != null) { --- 656,677 ---- } if (modules != null) { ! if(frozenModules == null) ! frozenModules = new java.util.Hashtable(); ! ! // System.err.println("modules: "); // ?? dbg ! for (int i = 0; i < modules.length; i++) { ! String modname = modules[i]; ! // System.err.print(modname + " "); // ?? dbg ! frozenModules.put(modname,PRESENT); ! // py pkgs are potentially java pkgs too. ! if (modname.endsWith(".__init__")) { ! String jpkg = modname.substring(0,modname.length()-9); ! PySystemState.add_package(jpkg); ! // System.err.print(":j "); // ?? dbg ! } ! } ! // System.out.println(); // ?? dbg } if (packages != null) { *************** *** 665,669 **** PyObject mod; ! Class modClass = Py.findClass(module+"$_PyInner"); if (modClass != null) { //System.err.println("found as class: "+modClass); --- 710,714 ---- PyObject mod; ! Class modClass = Py.findClass(module+"$_PyInner"); // ??pending: findClass or should avoid sys.path loading? if (modClass != null) { //System.err.println("found as class: "+modClass); *************** *** 700,704 **** Class mainClass=null; try { ! mainClass = Class.forName(module); } catch (ClassNotFoundException exc) { System.err.println("Error running main. Can't find: "+module); --- 745,749 ---- Class mainClass=null; try { ! mainClass = Class.forName(module); // ??pending: should use Py.findClass? } catch (ClassNotFoundException exc) { System.err.println("Error running main. Can't find: "+module); *************** *** 724,728 **** Class mainClass=null; try { ! mainClass = Class.forName(module); } catch (ClassNotFoundException exc) { System.err.println("Error running main. Can't find: "+module); --- 769,773 ---- Class mainClass=null; try { ! mainClass = Class.forName(module); // ??pending: should use Py.findClass? } catch (ClassNotFoundException exc) { System.err.println("Error running main. Can't find: "+module); *************** *** 1370,1375 **** if (proxyClass != null) pyclass.proxyClass = proxyClass; ! ! pyclass.init(name, new PyTuple(bases), dict); return pyclass; } --- 1415,1420 ---- if (proxyClass != null) pyclass.proxyClass = proxyClass; ! ! pyclass.init(name, new PyTuple(bases), dict); return pyclass; } Index: PyJavaClass.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyJavaClass.java,v retrieving revision 2.23 retrieving revision 2.24 diff -C2 -r2.23 -r2.24 *** PyJavaClass.java 2000/10/28 12:45:06 2.23 --- PyJavaClass.java 2000/11/17 12:32:43 2.24 *************** *** 74,79 **** return; initializing = true; ! if (proxyClass == null) init(Py.findClassEx(__name__)); init__bases__(proxyClass); init__dict__(); --- 74,80 ---- return; initializing = true; ! if (proxyClass == null) { init(Py.findClassEx(__name__)); + } init__bases__(proxyClass); init__dict__(); *************** *** 738,751 **** private PyObject findInnerClass(String name) { ! try { ! Class innerClass = Class.forName(__name__+"$"+name); ! PyJavaClass jinner = new PyJavaInnerClass(innerClass, this); ! __dict__.__setitem__(name, jinner); ! return jinner; ! } catch (ClassNotFoundException exc) { ! return null; ! } catch (Throwable t) { ! throw Py.JavaError(t); ! } } --- 739,748 ---- private PyObject findInnerClass(String name) { ! Class innerClass = Py.relFindClass(getProxyClass(),__name__+"$"+name); ! if (innerClass == null) return null; ! ! PyJavaClass jinner = new PyJavaInnerClass(innerClass, this); ! __dict__.__setitem__(name, jinner); ! return jinner; } Index: PyJavaPackage.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyJavaPackage.java,v retrieving revision 2.2 retrieving revision 2.3 diff -C2 -r2.2 -r2.3 *** PyJavaPackage.java 2000/10/28 12:07:31 2.2 --- PyJavaPackage.java 2000/11/17 12:32:43 2.3 *************** *** 7,15 **** public class PyJavaPackage extends PyObject { public String __name__; ! public PyObject __dict__; ! public String _unparsedAll; public String __file__; //public PyList __all__; public static PyClass __class__; public PyJavaPackage(String name) { --- 7,25 ---- public class PyJavaPackage extends PyObject { public String __name__; ! ! ! public PyStringMap __dict__; ! //public String _unparsedAll; ! /** Its keys are the names of statically known classes. ! * E.g. from jars pre-scan. ! */ ! public PyStringMap clsSet; public String __file__; //public PyList __all__; + /** (Control) package manager whose hierarchy contains this java pkg. + */ + public PackageManager __mgr__; + public static PyClass __class__; public PyJavaPackage(String name) { *************** *** 17,32 **** } ! protected PyJavaPackage __parent__ = null; ! public PyJavaPackage(String name, String jarfile) { this(name, null, jarfile); } ! public PyJavaPackage(String name, PyJavaPackage parent, String jarfile) { super(__class__); ! __parent__ = parent; ! if (jarfile == null && parent != null) ! jarfile = __parent__.__file__; __file__ = jarfile; __name__ = name; __dict__ = new PyStringMap(); __dict__.__setitem__("__name__", new PyString(__name__)); --- 27,52 ---- } ! public PyJavaPackage(String name,String jarfile) { this(name, null, jarfile); } ! public PyJavaPackage(String name,PackageManager mgr) { ! this(name, mgr, null); ! } ! ! ! public PyJavaPackage(String name,PackageManager mgr,String jarfile) { super(__class__); ! __file__ = jarfile; __name__ = name; + + if( mgr == null ) + __mgr__ = PySystemState.packageManager; // default + else + __mgr__ = mgr; + + clsSet= new PyStringMap(); + __dict__ = new PyStringMap(); __dict__.__setitem__("__name__", new PyString(__name__)); *************** *** 45,226 **** lastName = name.substring(dot+1, name.length()); } - if (jarfile != null) { - if (!jarfile.equals(__file__)) { - __file__ = null; - } - } firstName = firstName.intern(); PyJavaPackage p = (PyJavaPackage)__dict__.__finditem__(firstName); if (p == null) { ! p = new PyJavaPackage(__name__+'.'+firstName, this, jarfile); } ! __dict__.__setitem__(firstName, p); ! if (lastName != null) ! return p.addPackage(lastName, jarfile); ! else ! return p; } - - private PyObject __path__ = null; - protected PyObject getPath() { - if (__path__ != null) - return __path__; - //System.err.println("finding path for: "+__name__); - - if (__name__.length() == 0) { - __path__ = Py.getSystemState().path; - return __path__; - } - - PyJavaPackage parent = __parent__; - PyList rootPath; - if (parent == null) { - rootPath = Py.getSystemState().path; - } else { - PyObject tmp = __parent__.getPath(); - if (tmp == Py.None) { - __path__ = Py.None; - return __path__; - } - rootPath = (PyList)tmp; - } - - PyList path = new PyList(); - - if (Py.frozen) { - __path__ = path; - return __path__; - } - - // Search through directories in rootPath looking for appropriate - // subdir - int n = rootPath.__len__(); - - String name = __name__; - int dot = name.lastIndexOf('.'); - if (dot != -1) - name = name.substring(dot+1, name.length()); - - for (int i=0; i<n; i++) { - String dirName = rootPath.get(i).toString(); - File dir = new File(dirName, name); - //System.err.println("pkg: "+__name__+", looking for: "+dir); - if (dir.isDirectory()) { - //System.err.println("found: "+dir.getPath()); - path.append(new PyString(dir.getPath())); - } - } - //Py.println(path); - if (path.__len__() == 0) { - __path__ = Py.None; - } else { - __path__ = path; - } - return __path__; - } ! private PyObject __jdir__; ! private boolean jdirinit = false; ! public PyObject getDirPackage() { ! if (jdirinit) ! return __jdir__; ! jdirinit = true; ! ! if (__name__.length() == 0) { ! __jdir__ = PySystemState.packageManager.topDirectoryPackage; ! return __jdir__; ! } ! ! PyJavaPackage parent = __parent__; ! PyObject ppkg; ! if (parent == null) { ! ppkg = PySystemState.packageManager.topDirectoryPackage; ! } else { ! ppkg = parent.getDirPackage(); ! } ! ! if (ppkg == null) { ! __jdir__ = null; ! return null; ! } ! String name = __name__; ! int dot = name.lastIndexOf('.'); ! if (dot != -1) ! name = name.substring(dot+1, name.length()).intern(); ! __jdir__ = ppkg.__findattr__(name); ! return __jdir__; ! } ! ! private void initialize() { ! if (__dict__ == null) ! __dict__ = new PyStringMap(); ! ! if (_unparsedAll != null) { ! //__all__ = new PyList(); ! StringTokenizer tok = new StringTokenizer(_unparsedAll, ","); ! while (tok.hasMoreTokens()) { ! String p = tok.nextToken(); ! String cname = p.trim().intern(); ! __dict__.__setitem__(cname, PyJavaClass.lookup(__name__+'.'+ ! cname, null)); ! //__all__.append(new PyString(p.trim())); ! } ! _unparsedAll = null; } } public PyObject __dir__() { ! initialize(); ! if (__dict__ instanceof PyStringMap) { ! return ((PyStringMap)__dict__).keys(); ! } else { ! return __dict__.invoke("keys"); ! } } public PyObject __findattr__(String name) { ! if (__dict__ == null) ! __dict__ = new PyStringMap(); ! PyObject ret = __dict__.__finditem__(name); ! if (ret != null) ! return ret; Class c; - if (__name__.length()>0) - c = Py.findClassEx(__name__+'.'+name); - else - c = Py.findClassEx(name); ! if (c != null) { ! ret = PyJavaClass.lookup(c); ! __dict__.__setitem__(name, ret); ! return ret; ! } if (name == "__name__") return new PyString(__name__); if (name == "__dict__") return __dict__; ! if (name == "__file__" && __file__ != null) ! return new PyString(__file__); ! ! // Name not found - check for Java dir package ! PyObject pyjd = getDirPackage(); ! if (pyjd != null) ! ret = pyjd.__findattr__(name); ! ! if (ret == null) { ! // Name not found - check for a Python package/module ! PyObject path = getPath(); ! if (path == Py.None) ! return null; ! ret = imp.loadFromPath(name, (__name__+'.'+name).intern(), ! (PyList)path); } ! ! if (ret != null) ! __dict__.__setitem__(name, ret); ! return ret; ! //return super.__findattr__(name); } --- 65,142 ---- lastName = name.substring(dot+1, name.length()); } firstName = firstName.intern(); PyJavaPackage p = (PyJavaPackage)__dict__.__finditem__(firstName); if (p == null) { ! p = new PyJavaPackage(__name__.length()==0?firstName:__name__+'.'+firstName, __mgr__, jarfile); ! __dict__.__setitem__(firstName, p); ! } else { // this code is ok here, because this is not needed for a top level package ! if (jarfile == null || !jarfile.equals(p.__file__)) p.__file__ = null; } ! if (lastName != null) return p.addPackage(lastName, jarfile); ! else return p; } ! public PyObject addClass(String name,Class c) { ! PyObject ret = PyJavaClass.lookup(c); ! __dict__.__setitem__(name.intern(), ret); ! return ret; ! } ! public PyObject addLazyClass(String name) { ! PyObject ret = PyJavaClass.lookup(__name__+'.'+name,null); ! __dict__.__setitem__(name.intern(), ret); ! return ret; ! } ! /** Add statically known classes. ! * @param classes their names as comma-separated string ! */ ! public void addPlaceholders(String classes) { ! StringTokenizer tok = new StringTokenizer(classes, ","); ! while (tok.hasMoreTokens()) { ! String p = tok.nextToken(); ! String name = p.trim().intern(); ! if ( clsSet.__finditem__(name) == null) clsSet.__setitem__(name, Py.One); } } public PyObject __dir__() { ! return __mgr__.doDir(this,false,false); ! } ! ! /** Used for 'from xyz import *', dynamically dir pkg filling up __dict__. ! * It uses {@link PackageManager#doDir} implementation furnished by the control ! * package manager with instatiate true. The package manager should lazily load ! * classes with {@link #addLazyClass} in the package. ! * ! * @return list of member names ! */ ! public PyObject fillDir() { ! return __mgr__.doDir(this,true,false); } public PyObject __findattr__(String name) { ! PyObject ret = __dict__.__finditem__(name); ! if (ret != null) return ret; ! Class c; ! c = __mgr__.findClass(__name__,name); ! ! if (c != null) return addClass(name,c); ! if (name == "__name__") return new PyString(__name__); if (name == "__dict__") return __dict__; ! if (name == "__file__") { ! if (__file__ != null) return new PyString(__file__); ! ! return Py.None; } ! ! if(__mgr__.packageExists(__name__,name)) return addPackage(name); ! ! return null; } Index: PyModule.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyModule.java,v retrieving revision 2.3 retrieving revision 2.4 diff -C2 -r2.3 -r2.4 *** PyModule.java 2000/09/28 11:37:37 2.3 --- PyModule.java 2000/11/17 12:32:43 2.4 *************** *** 18,64 **** PyObject ret; ret = __dict__.__finditem__(attr); if (ret == null) { ! PyObject path = __dict__.__finditem__("__path__"); ! if (path != null) { ! PyObject pyname = __dict__.__finditem__("__name__"); ! ! if (pyname != null) { ! String name = pyname.__str__().toString(); ! ! if (path == Py.None) { ! ret = imp.loadFromClassLoader( ! (name+'.'+attr).intern(), ! Py.getSystemState().getClassLoader()); ! } ! else if (path instanceof PyList) { ! ret = imp.loadFromPath(attr, (name+'.'+attr).intern(), ! (PyList)path); ! } ! else { ! throw Py.TypeError("__path__ must be list or None"); ! } ! ! if (ret == null) { ! ret = PySystemState.packageManager.lookupName( ! name+'.'+attr); ! /*Class c = Py.findClass(name+'.'+attr); ! if (c != null) ! ret = PyJavaClass.lookup(c);*/ ! } ! ! if (ret != null) { ! // Allow a package component to change its own meaning ! PyObject tmp = __dict__.__finditem__(attr); ! if (tmp != null) ! ret = tmp; ! __dict__.__setitem__(attr, ret); ! return ret; ! } ! } ! // Not found in package ! } ! return super.__findattr__(attr); } ! return ret; //ret._doget(this); } --- 18,69 ---- PyObject ret; ret = __dict__.__finditem__(attr); + if (ret != null) return ret; + + PyObject path = __dict__.__finditem__("__path__"); + PyObject pyname = __dict__.__finditem__("__name__"); + + if (path == null || pyname == null) return super.__findattr__(attr); + + String name = pyname.__str__().toString(); + + if (path == Py.None) { + /* disabled: + ret = imp.loadFromClassLoader( + (name+'.'+attr).intern(), + Py.getSystemState().getClassLoader()); + */ + } + else if (path instanceof PyList) { + ret = imp.loadFromPath(attr, (name+'.'+attr).intern(), + (PyList)path); + } + else { + throw Py.TypeError("__path__ must be list or None"); + } + if (ret == null) { ! ret = super.__findattr__(attr); ! if (ret != null) return ret; ! } ! ! if (ret == null) { ! ret = PySystemState.packageManager.lookupName( ! name+'.'+attr); ! /*Class c = Py.findClass(name+'.'+attr); ! if (c != null) ! ret = PyJavaClass.lookup(c);*/ ! } ! ! if (ret != null) { ! // Allow a package component to change its own meaning ! PyObject tmp = __dict__.__finditem__(attr); ! if (tmp != null) ! ret = tmp; ! __dict__.__setitem__(attr, ret); ! return ret; } ! ! return null; ! } Index: PySystemState.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PySystemState.java,v retrieving revision 2.29 retrieving revision 2.30 diff -C2 -r2.29 -r2.30 *** PySystemState.java 2000/10/11 12:52:24 2.29 --- PySystemState.java 2000/11/17 12:32:43 2.30 *************** *** 380,384 **** pkgdir = null; } ! packageManager = new PackageManager(pkgdir, props); } --- 380,384 ---- pkgdir = null; } ! packageManager = new SysPackageManager(pkgdir, props); } Index: imp.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/imp.java,v retrieving revision 2.26 retrieving revision 2.27 diff -C2 -r2.26 -r2.27 *** imp.java 2000/10/28 12:07:31 2.26 --- imp.java 2000/11/17 12:32:43 2.27 *************** *** 107,111 **** if (filename == null) filename = "<unknown>"; ! org.python.parser.SimpleNode node; try { node = parser.parse(fp, "exec", filename); --- 107,111 ---- if (filename == null) filename = "<unknown>"; ! org.python.parser.SimpleNode node = null; //*Forte* try { node = parser.parse(fp, "exec", filename); *************** *** 155,159 **** private static BytecodeLoader syspathJavaLoader = null; ! public static BytecodeLoader getSyspathJavaLoader() { if (syspathJavaLoader == null) syspathJavaLoader = new BytecodeLoader(); --- 155,159 ---- private static BytecodeLoader syspathJavaLoader = null; ! public static synchronized BytecodeLoader getSyspathJavaLoader() { if (syspathJavaLoader == null) syspathJavaLoader = new BytecodeLoader(); *************** *** 217,232 **** PyList path) { ! //System.out.println("precomp: "+name+", "+modName); ! Class c = findPyClass(modName); ! if (c == null) { ! //System.err.println("trying: "+modName+".__init__$_PyInner"); ! c = findPyClass(modName+".__init__"); ! if (c == null) return null; ! //System.err.println("found: "+modName+".__init__$_PyInner"); ! PyModule m = addModule(modName); ! m.__dict__.__setitem__("__path__", new PyList()); ! } ! //System.err.println("creating: "+modName+", "+c); ! return createFromClass(modName, c); } --- 217,242 ---- PyList path) { ! if (Py.frozenModules != null) { ! //System.out.println("precomp: "+name+", "+modName); ! Class c; ! ! if (Py.frozenModules.get(modName+".__init__") != null) { ! //System.err.println("trying: "+modName+".__init__$_PyInner"); ! c = findPyClass(modName+".__init__"); ! if (c == null) return null; ! //System.err.println("found: "+modName+".__init__$_PyInner"); ! PyModule m = addModule(modName); ! m.__dict__.__setitem__("__path__", new PyList()); ! } ! else if (Py.frozenModules.get(modName) != null) { ! c = findPyClass(modName); ! if (c == null) return null; ! } ! else return null; ! ! //System.err.println("creating: "+modName+", "+c); ! return createFromClass(modName, c); ! } ! return null; } *************** *** 236,245 **** static PyObject loadFromPath(String name, String modName, PyList path) { ! if (Py.frozen) ! return loadPrecompiled(name, modName, path); String pyName = name+".py"; String className = name+"$py.class"; - String javaName = name+".class"; int n = path.__len__(); --- 246,255 ---- static PyObject loadFromPath(String name, String modName, PyList path) { ! //System.err.println("load-from-path:"+name+" "+modName+" "+path); // ?? dbg ! PyObject o = loadPrecompiled(name, modName, path); ! if (o != null) return o; String pyName = name+".py"; String className = name+"$py.class"; int n = path.__len__(); *************** *** 260,266 **** // this correctly. if (dirName.length() == 0) { ! String userdir = System.getProperty("user.dir"); ! if (userdir != null) ! dirName = userdir; } --- 270,274 ---- // this correctly. if (dirName.length() == 0) { ! dirName = null; } *************** *** 275,279 **** pkgPath.append(new PyString(dir.toString())); m.__dict__.__setitem__("__path__", pkgPath); ! PyObject o = loadFromPath("__init__", modName, pkgPath); if (o == null) continue; --- 283,287 ---- pkgPath.append(new PyString(dir.toString())); m.__dict__.__setitem__("__path__", pkgPath); ! o = loadFromPath("__init__", modName, pkgPath); if (o == null) continue; *************** *** 304,317 **** false); } - - File javaFile = new File(dirName, javaName); - if (javaFile.isFile()) { - try { - return createFromClass(modName, makeStream(javaFile)); - } catch (ClassFormatError exc) { - throw Py.ImportError("bad java class file in: "+ - javaFile.toString()); - } - } } --- 312,315 ---- *************** *** 344,361 **** private static PyObject load(String name, PyList path) { PyObject ret = loadBuiltin(name, path); - if (ret != null) return ret; - - ret = PySystemState.packageManager.jarFindName(name); if (ret != null) return ret; ! ret = loadFromPath(name, path); if (ret != null) return ret; - - if (Py.frozen) { - Class c = Py.findClassEx(name); - if (c != null) return createFromClass(name, c); - } ! ret = PySystemState.packa... [truncated message content] |
From: Finn B. <bc...@us...> - 2000-11-16 19:35:38
|
Update of /cvsroot/jython/jython In directory slayer.i.sourceforge.net:/tmp/cvs-serv5369 Modified Files: ACKNOWLEDGMENTS Log Message: Added Dj. Index: ACKNOWLEDGMENTS =================================================================== RCS file: /cvsroot/jython/jython/ACKNOWLEDGMENTS,v retrieving revision 2.4 retrieving revision 2.5 diff -C2 -r2.4 -r2.5 *** ACKNOWLEDGMENTS 2000/10/29 17:01:32 2.4 --- ACKNOWLEDGMENTS 2000/11/16 19:35:34 2.5 *************** *** 8,14 **** inventor Guido van Rossum. ! You can contact the JPython maintainers directly via ! jp...@py..., or the JPython community at ! jpy...@py.... Finn Bock has been a frequent and valuable contributor to the --- 8,14 ---- inventor Guido van Rossum. ! You can contact the Jython maintainers directly via ! jyt...@li..., or the Jython community at ! jyt...@li.... Finn Bock has been a frequent and valuable contributor to the *************** *** 39,42 **** --- 39,43 ---- Tim Hochberg Bernhard Bablok + Dj Walker-Morgan |
From: Finn B. <bc...@us...> - 2000-11-16 19:34:27
|
Update of /cvsroot/jython/jython In directory slayer.i.sourceforge.net:/tmp/cvs-serv5245 Added Files: build.xml Log Message: First version. Contributed by Dj. --- NEW FILE --- <project name="jython" default="compile" basedir="."> <target name="init"> <property name="sourceDir" value="." /> <property name="outputDir" value="build" /> <available classname="java.util.List" property="java2" /> <!-- This propery should be specified in the ant.property file property name="javaccHome" value="/opt/javacc2.0/bin/lib" /--> <!-- Give users a change to override editing this file--> <property file="ant.properties" /> </target> <target name="clean" depends="init"> <delete dir="${outputDir}/" /> <property name="parser" value="${sourceDir}/org/python/parser" /> <delete file="${parser}/python.jj" /> <delete file="${parser}/PythonGrammar.java" /> <delete file="${parser}/PythonGrammarConstants.java" /> <delete file="${parser}/PythonGrammarTokenManager.java" /> <delete file="${parser}/PythonGrammarTreeConstants.java" /> <delete file="${parser}/Node.java" /> <delete file="${parser}/Token.java" /> <delete file="${parser}/ASCII_CharStream.java" /> <delete file="${parser}/JJTPythonGrammarState.java" /> </target> <target name="prepare" depends="init"> <mkdir dir="${outputDir}" /> </target> <target name="tree" depends="prepare"> <jjtree javacchome="${javaccHome2}" target="org/python/parser/python.jjt" outputdirectory="org/python/parser/" /> </target> <target name="parser" depends="tree"> <javacc javacchome="${javaccHome2}" target="org/python/parser/python.jj" outputdirectory="org/python/parser/" /> <!-- Damn! The task above assumes that the generated name is basename of the input file. So we fake it to be the case--> <touch file="org/python/parser/python.java" /> </target> <!-- Only do this task if our environment is java2. --> <target name="checkjavaversion" unless="java2"> <property name="excludejava2files" value="CollectionProxy2.java,Java2Accessibility.java" /> </target> <target name="compile" depends="prepare,parser,checkjavaversion"> <javac srcdir="${sourceDir}/" includes="org/**" destdir="${outputDir}/" excludes="org/python/parser/python.java,${exludejava2files}" /> </target> <target name="jar" depends="compile"> <jar jarfile="jython.jar" basedir="${outputDir}" includes="**/*.class" /> </target> <target name="all" depends="init,clean,prepare,parser,compile,jar"> </target> </project> |
From: Finn B. <bc...@us...> - 2000-11-14 20:36:21
|
Update of /cvsroot/jython/htdocs/applets In directory slayer.i.sourceforge.net:/tmp/cvs-serv27230 Modified Files: index.ht Log Message: Give the HelloWorld applet a name and make the JythonLoader wait for that name to become avilable. Index: index.ht =================================================================== RCS file: /cvsroot/jython/htdocs/applets/index.ht,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** index.ht 2000/11/12 22:50:30 1.1 --- index.ht 2000/11/14 20:36:18 1.2 *************** *** 11,14 **** --- 11,15 ---- <CENTER> <APPLET Code="JythonLoader" WIDTH="220" HEIGHT="90" ALIGN="BOTTOM"> + <param name=waitFor value="HelloWorld"> </APPLET> </CENTER> *************** *** 22,28 **** <P>Once the library has loaded, your first Jython applet will appear below: <CENTER> ! <APPLET ARCHIVE="appletdemo.jar" CODE="HelloWorld" WIDTH="160" HEIGHT="50" ALIGN="BOTTOM" alt="This browser doesn't support JDK 1.1 applets."> ! <PARAM NAME="cabbase0" VALUE="appletdemo.cab"> ! <H3>Something has gone wrong loading this applet.</H3> </APPLET> </CENTER> --- 23,33 ---- <P>Once the library has loaded, your first Jython applet will appear below: <CENTER> ! <APPLET CODE="HelloWorld" WIDTH="160" HEIGHT="50" ! ARCHIVE="appletdemo.jar" ! NAME="HelloWorld" ! ALIGN="BOTTOM" ! alt="This browser doesn't support JDK 1.1 applets."> ! <PARAM NAME="cabbase0" VALUE="appletdemo.cab"> ! <H3>Something has gone wrong loading this applet.</H3> </APPLET> </CENTER> |
From: Finn B. <bc...@us...> - 2000-11-14 20:35:17
|
Update of /cvsroot/jython/htdocs/applets In directory slayer.i.sourceforge.net:/tmp/cvs-serv27108 Modified Files: JythonLoader.java Log Message: Do not use getAppletContext().getApplets(). It can cause security exceptions on IE if there are applets loaded from other domains. Instead we wait for a specificly named applet to become available. Index: JythonLoader.java =================================================================== RCS file: /cvsroot/jython/htdocs/applets/JythonLoader.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** JythonLoader.java 2000/11/12 22:51:37 1.1 --- JythonLoader.java 2000/11/14 20:35:12 1.2 *************** *** 7,10 **** --- 7,11 ---- Thread timer; long initialTime; + String waitFor = "HelloWorld"; public void init() { *************** *** 38,41 **** --- 39,46 ---- bag.setConstraints(etime, c); add(etime); + + String n = getParameter("waitFor"); + if (n != null) + waitFor = n; } *************** *** 51,62 **** private int activeApplets() { ! Enumeration e = getAppletContext().getApplets(); ! int n; ! for (n=0; e.hasMoreElements(); ) { ! Applet a = (Applet)e.nextElement(); ! if (a != null && a.isActive()) ! n++; ! } ! return n; } --- 56,63 ---- private int activeApplets() { ! Applet a = getAppletContext().getApplet(waitFor); ! if (a != null) ! return 2; ! return 1; } |
From: Finn B. <bc...@us...> - 2000-11-14 20:32:54
|
Update of /cvsroot/jython/htdocs In directory slayer.i.sourceforge.net:/tmp/cvs-serv27039 Modified Files: download.ht Log Message: Nightly snapshots of the CVS added. Index: download.ht =================================================================== RCS file: /cvsroot/jython/htdocs/download.ht,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** download.ht 2000/11/12 22:47:41 1.1 --- download.ht 2000/11/14 20:32:51 1.2 *************** *** 7,10 **** --- 7,14 ---- available via CVS</a>!</em> + <p>Nightly snapshots of the CVS repository are also available as + <a href="http://jython.sourceforge.net/cvssnaps/jython-nightly.tar.gz">.tar.gz</a> + and <a href="http://jython.sourceforge.net/cvssnaps/jython-nightly.zip">.zip</a> files. + <p>Here are the steps you need to perform in order to download Jython. Once you've done this, you should read the |
From: Finn B. <bc...@us...> - 2000-11-13 10:28:59
|
Update of /cvsroot/jython/htdocs/applets In directory slayer.i.sourceforge.net:/tmp/cvs-serv717/applets Added Files: .cvsignore Log Message: First version. --- NEW FILE --- *.html appletdemo.cab appletdemo.jar *.class *.bat |