From: <fwi...@us...> - 2008-10-27 13:19:34
|
Revision: 5517 http://jython.svn.sourceforge.net/jython/?rev=5517&view=rev Author: fwierzbicki Date: 2008-10-27 13:19:32 +0000 (Mon, 27 Oct 2008) Log Message: ----------- Fix for bug http://bugs.jython.org/issue1158, where the __builtin__ compile function does not recognize when it is passed an AST as the first argument. Modified Paths: -------------- trunk/jython/src/org/python/core/__builtin__.java Modified: trunk/jython/src/org/python/core/__builtin__.java =================================================================== --- trunk/jython/src/org/python/core/__builtin__.java 2008-10-27 03:09:47 UTC (rev 5516) +++ trunk/jython/src/org/python/core/__builtin__.java 2008-10-27 13:19:32 UTC (rev 5517) @@ -274,7 +274,10 @@ if (args.length > 4) { dont_inherit = Py.py2boolean(args[4]); } - + modType ast = py2node(args[0]); + if (ast != null) { + return __builtin__.compile(ast, args[1].toString(), args[2].toString(), flags, dont_inherit); + } if (args[0] instanceof PyUnicode) { flags += PyTableCode.PyCF_SOURCE_IS_UTF8; } @@ -291,6 +294,21 @@ public PyObject getModule() { return module; } + + /** + * @returns modType if obj is a wrapper around an AST modType + * + * XXX: Reaches deep into implementation details -- needs to be reviewed if + * PyInstance is significantly changed. + */ + private static modType py2node(PyObject obj) { + if (obj != null && obj instanceof PyInstance && ((PyInstance)obj).javaProxy + instanceof modType) { + return (modType)((PyInstance)obj).javaProxy; + } + return null; + } + } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |