Issue1743933

classification
Title: odd syntax bug
Type: Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution: invalid
Dependencies: Superseder:
Assigned To: Nosy List: cgroves, cookconsulting
Priority: normal Keywords:

Created on 2007-06-27.00:22:32 by cookconsulting, last changed 2007-06-27.04:55:23 by cgroves.

Files
File name Uploaded Description Edit Remove
xml2obj2.py cookconsulting, 2007-06-27.00:22:32 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/298721/index_txt
Messages
msg1656 (view) Author: Todd Cook (cookconsulting) Date: 2007-06-27.00:22:32
/* 
First time posting an error report here, so hope this helps. Otherwise, I love Jython!

error detailed inline
 attached file from the PythonCookbook:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/298721/index_txt
 NOTE: the file works from the command prompt Python interpreter

*/

/**
 * User: tcook
 * Date: Jun 25, 2007
 */

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.BasicConfigurator;
import org.python.util.PythonInterpreter;
import org.python.core.PyInteger;
import org.python.core.PyObject;
import org.python.core.PyString;

import java.util.Properties;

public class JythonTest
{
    private static Log log = LogFactory.getLog(JythonTest.class);

    public static void main(String[] args)
    {
        try
        {
            // Set up a simple configuration that logs on the console.
            BasicConfigurator.configure();
            System.out.println("Jython Test ");

            // to find modules, they must be pushed into the path
            Properties props = new Properties();
            props.setProperty("python.path", "/users/tcook/Documents/pythonScripts/");
            PythonInterpreter.initialize(System.getProperties(), props, new String[]{""});
            PythonInterpreter interp = new PythonInterpreter();
            try
            {
                interp.exec ( "import xml2obj2 as xml2obj" ) ;
                /// xml2obj2.py exists in  /users/tcook/Documents/pythonScripts/

                //error is:
//                Jython Test 
//                Traceback (innermost last):
//                  File "<string>", line 1, in ?
//                  File "/users/tcook/Documents/pythonScripts/xml2obj2.py", line 138
//                                yield oChild
//                                                  ^
//                SyntaxError: invalid syntax
                

                // other stuff was planned, but it blows up...
                // note other programs and evaluation work in this same setup....


            } catch (Exception e)
            {
                e.printStackTrace();
            }
        }
        catch (Exception e)
        {
            log.error(e);
        }
    }

}
msg1657 (view) Author: Todd Cook (cookconsulting) Date: 2007-06-27.00:33:55
This is regarding: 
Jython 2.2 RC1!
my system version is: 
Python 2.3.5 (#1, Jan 13 2006, 20:13:11)
msg1658 (view) Author: Charlie Groves (cgroves) Date: 2007-06-27.04:55:23
The syntax error is because the program is using the 'yield' keyword to make a generator, which didn't appear until Python 2.3.  It's available in Jython 2.2 but only if you add 'from __future__ import generators' as the first line of the file.  Just pop that in there and the syntax error will go away.
History
Date User Action Args
2007-06-27 00:22:32cookconsultingcreate