From: <fwi...@us...> - 2008-10-16 21:16:03
|
Revision: 5447 http://jython.svn.sourceforge.net/jython/?rev=5447&view=rev Author: fwierzbicki Date: 2008-10-16 21:15:59 +0000 (Thu, 16 Oct 2008) Log Message: ----------- put in null guard for cflags call. cflags can definitely be null at this point in the code. Modified Paths: -------------- trunk/jython/src/org/python/core/Py.java Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2008-10-16 20:59:53 UTC (rev 5446) +++ trunk/jython/src/org/python/core/Py.java 2008-10-16 21:15:59 UTC (rev 5447) @@ -1697,7 +1697,7 @@ } byte[] bytes; - if (cflags.dont_imply_dedent) { + if (cflags != null && cflags.dont_imply_dedent) { bytes = StringUtil.toBytes(data + "\n"); } else { bytes = StringUtil.toBytes(data + "\n\n"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-11-22 19:18:57
|
Revision: 5598 http://jython.svn.sourceforge.net/jython/?rev=5598&view=rev Author: fwierzbicki Date: 2008-11-22 19:18:53 +0000 (Sat, 22 Nov 2008) Log Message: ----------- Fixes bug http://bugs.jython.org/issue1174 which reveals a corner case where CompilerFlags can come out as null. Not positive that we should be passing the "flags" value down when there is no frame, but this is probably right. Put an XXX in so it can be looked at again later. Modified Paths: -------------- trunk/jython/src/org/python/core/Py.java Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2008-11-21 14:59:28 UTC (rev 5597) +++ trunk/jython/src/org/python/core/Py.java 2008-11-22 19:18:53 UTC (rev 5598) @@ -1674,6 +1674,9 @@ PyFrame frame = Py.getFrame(); if (frame != null && frame.f_code != null) { cflags = new CompilerFlags(frame.f_code.co_flags | flags); + } else { + //XXX: should this really pass flags or not? + cflags = new CompilerFlags(flags); } } return cflags; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-11-22 20:39:56
|
Revision: 5599 http://jython.svn.sourceforge.net/jython/?rev=5599&view=rev Author: fwierzbicki Date: 2008-11-22 20:39:54 +0000 (Sat, 22 Nov 2008) Log Message: ----------- Removed XXX -- looking at the code some more makes me comfortable with passing "flags" on. Modified Paths: -------------- trunk/jython/src/org/python/core/Py.java Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2008-11-22 19:18:53 UTC (rev 5598) +++ trunk/jython/src/org/python/core/Py.java 2008-11-22 20:39:54 UTC (rev 5599) @@ -1675,7 +1675,6 @@ if (frame != null && frame.f_code != null) { cflags = new CompilerFlags(frame.f_code.co_flags | flags); } else { - //XXX: should this really pass flags or not? cflags = new CompilerFlags(flags); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-01-18 00:53:16
|
Revision: 5944 http://jython.svn.sourceforge.net/jython/?rev=5944&view=rev Author: cgroves Date: 2009-01-18 00:53:10 +0000 (Sun, 18 Jan 2009) Log Message: ----------- ecj likes this, but javac disputes that it's compilable, so go back to the old way Modified Paths: -------------- trunk/jython/src/org/python/core/Py.java Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2009-01-17 23:57:54 UTC (rev 5943) +++ trunk/jython/src/org/python/core/Py.java 2009-01-18 00:53:10 UTC (rev 5944) @@ -84,10 +84,13 @@ public static long TPFLAGS_BASETYPE = 1L << 10; /** Builtin types that are used to setup PyObject. */ - static final Set<Class<?>> BOOTSTRAP_TYPES = Generic.set(PyObject.class, - PyType.class, - PyBuiltinCallable.class, - PyDataDescr.class); + static final Set<Class<?>> BOOTSTRAP_TYPES = Generic.set(); + static { + BOOTSTRAP_TYPES.add(PyObject.class); + BOOTSTRAP_TYPES.add(PyType.class); + BOOTSTRAP_TYPES.add(PyBuiltinCallable.class); + BOOTSTRAP_TYPES.add(PyDataDescr.class); + } /** A unique object to indicate no conversion is possible in __tojava__ methods **/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-02-09 02:22:13
|
Revision: 6023 http://jython.svn.sourceforge.net/jython/?rev=6023&view=rev Author: fwierzbicki Date: 2009-02-09 01:40:53 +0000 (Mon, 09 Feb 2009) Log Message: ----------- Fix for http://bugs.jython.org/issue1243. Thanks RJ Ryan for suggesting the fix. Modified Paths: -------------- trunk/jython/src/org/python/core/Py.java Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2009-02-07 21:26:31 UTC (rev 6022) +++ trunk/jython/src/org/python/core/Py.java 2009-02-09 01:40:53 UTC (rev 6023) @@ -1623,7 +1623,7 @@ // w/o compiler-flags public static PyObject compile(InputStream istream, String filename, String kind) { - return compile_flags(istream, filename, kind, null); + return compile_flags(istream, filename, kind, new CompilerFlags()); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-03-30 07:17:49
|
Revision: 6118 http://jython.svn.sourceforge.net/jython/?rev=6118&view=rev Author: thobes Date: 2009-03-30 07:17:38 +0000 (Mon, 30 Mar 2009) Log Message: ----------- Fix to bug 1294. Modified Paths: -------------- trunk/jython/src/org/python/core/Py.java Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2009-03-29 23:21:00 UTC (rev 6117) +++ trunk/jython/src/org/python/core/Py.java 2009-03-30 07:17:38 UTC (rev 6118) @@ -1219,6 +1219,19 @@ public static void exec(PyObject o, PyObject globals, PyObject locals) { PyCode code; int flags = 0; + if (o instanceof PyTuple) { + PyTuple tuple = (PyTuple) o; + int len = tuple.__len__(); + if ((globals == null || globals.equals(None)) + && (locals == null || locals.equals(None)) + && (len >= 2 && len <= 3)) { + o = tuple.__getitem__(0); + globals = tuple.__getitem__(1); + if (len == 3) { + locals = tuple.__getitem__(2); + } + } + } if (o instanceof PyCode) { code = (PyCode) o; if (locals == null && o instanceof PyBaseCode && ((PyBaseCode) o).hasFreevars()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-05-26 06:38:55
|
Revision: 6378 http://jython.svn.sourceforge.net/jython/?rev=6378&view=rev Author: pjenvey Date: 2009-05-26 06:38:46 +0000 (Tue, 26 May 2009) Log Message: ----------- Thread ClassLoader can be null in the Finalizer thread (e.g. importing in __del__) Modified Paths: -------------- trunk/jython/src/org/python/core/Py.java Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2009-05-26 06:28:07 UTC (rev 6377) +++ trunk/jython/src/org/python/core/Py.java 2009-05-26 06:38:46 UTC (rev 6378) @@ -749,7 +749,7 @@ private static boolean secEnv = false; - public static Class findClass(String name) { + public static Class<?> findClass(String name) { try { ClassLoader classLoader = Py.getSystemState().getClassLoader(); if (classLoader != null) { @@ -771,8 +771,11 @@ } } - return Thread.currentThread().getContextClassLoader().loadClass(name); - + classLoader = Thread.currentThread().getContextClassLoader(); + if (classLoader != null) { + return classLoader.loadClass(name); + } + return null; } catch (ClassNotFoundException e) { // e.printStackTrace(); return null; @@ -785,7 +788,7 @@ } } - public static Class findClassEx(String name, String reason) { + public static Class<?> findClassEx(String name, String reason) { try { ClassLoader classLoader = Py.getSystemState().getClassLoader(); if (classLoader != null) { @@ -813,7 +816,11 @@ writeDebug("import", "trying " + name + " as " + reason + " in Class.forName"); - return Thread.currentThread().getContextClassLoader().loadClass(name); + classLoader = Thread.currentThread().getContextClassLoader(); + if (classLoader != null) { + return classLoader.loadClass(name); + } + return null; } catch (ClassNotFoundException e) { return null; } catch (IllegalArgumentException e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-10-17 02:11:52
|
Revision: 6865 http://jython.svn.sourceforge.net/jython/?rev=6865&view=rev Author: pjenvey Date: 2009-10-17 02:11:46 +0000 (Sat, 17 Oct 2009) Log Message: ----------- fast path lists along with tuples and avoid the overhead of __len__'ing generators which can be a somewhat common make_array argument Modified Paths: -------------- trunk/jython/src/org/python/core/Py.java Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2009-10-16 05:51:46 UTC (rev 6864) +++ trunk/jython/src/org/python/core/Py.java 2009-10-17 02:11:46 UTC (rev 6865) @@ -1904,23 +1904,29 @@ } } - static PyObject[] make_array(PyObject o) { - if (o instanceof PyTuple) { - return ((PyTuple) o).getArray(); + static PyObject[] make_array(PyObject iterable) { + // Special-case the common tuple and list cases, for efficiency + if (iterable instanceof PySequenceList) { + return ((PySequenceList) iterable).getArray(); } - // Guess result size and allocate space. + + // Guess result size and allocate space. The typical make_array arg supports + // __len__, with one exception being generators, so avoid the overhead of an + // exception from __len__ in their case int n = 10; - try { - n = o.__len__(); - } catch (PyException exc) { + if (!(iterable instanceof PyGenerator)) { + try { + n = iterable.__len__(); + } catch (PyException pye) { + // ok + } } List<PyObject> objs = new ArrayList<PyObject>(n); - for (PyObject item : o.asIterable()) { + for (PyObject item : iterable.asIterable()) { objs.add(item); } - PyObject dest[] = new PyObject[0]; - return (objs.toArray(dest)); + return objs.toArray(Py.EmptyObjects); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2011-03-21 23:11:31
|
Revision: 7260 http://jython.svn.sourceforge.net/jython/?rev=7260&view=rev Author: pjenvey Date: 2011-03-21 23:11:25 +0000 (Mon, 21 Mar 2011) Log Message: ----------- better support for Java exceptions in writeUnraisable Modified Paths: -------------- trunk/jython/src/org/python/core/Py.java Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2011-03-21 23:10:49 UTC (rev 7259) +++ trunk/jython/src/org/python/core/Py.java 2011-03-21 23:11:25 UTC (rev 7260) @@ -1208,15 +1208,10 @@ return buf.toString(); } - public static void writeUnraisable(Exception exc, PyObject obj) { - if (exc instanceof PyException) { - PyException pye = (PyException) exc; - stderr.println(String.format("Exception %s in %s ignored", - formatException(pye.type, pye.value, true), obj)); - } else { - // XXX: this could be better handled - exc.printStackTrace(); - } + public static void writeUnraisable(Throwable unraisable, PyObject obj) { + PyException pye = JavaError(unraisable); + stderr.println(String.format("Exception %s in %s ignored", + formatException(pye.type, pye.value, true), obj)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2011-04-01 18:35:42
|
Revision: 7281 http://jython.svn.sourceforge.net/jython/?rev=7281&view=rev Author: pjenvey Date: 2011-04-01 18:35:36 +0000 (Fri, 01 Apr 2011) Log Message: ----------- minor refactor Modified Paths: -------------- trunk/jython/src/org/python/core/Py.java Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2011-04-01 05:22:39 UTC (rev 7280) +++ trunk/jython/src/org/python/core/Py.java 2011-04-01 18:35:36 UTC (rev 7281) @@ -2053,10 +2053,7 @@ */ private static PyTuple abstractGetBases(PyObject cls) { PyObject bases = cls.__findattr__("__bases__"); - if (bases instanceof PyTuple) { - return (PyTuple) bases; - } - return null; + return bases instanceof PyTuple ? (PyTuple) bases : null; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |