Index: registry =================================================================== RCS file: /cvsroot/jython/jython/registry,v retrieving revision 2.14 diff -u -r2.14 registry --- registry 2001/06/04 10:43:32 2.14 +++ registry 2001/07/21 09:40:36 @@ -42,6 +42,12 @@ # This might be helpful on systems without system-level threads python.console.poll = false +# Setting this to a valid codec name will cause the console to use a +# different encoding when reading commands from the console. +# The default java encoding is still used when reading python sources +# from the filesystem. +#python.console.encoding = cp850 + # Setting this to false will allow Jython to provide access to # non-public fields, methods, and constructors of Java objects. python.security.respectJavaAccessibility = true Index: org/python/core/CompilerFlags.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/CompilerFlags.java,v retrieving revision 2.1 diff -u -r2.1 CompilerFlags.java --- org/python/core/CompilerFlags.java 2001/05/27 18:49:15 2.1 +++ org/python/core/CompilerFlags.java 2001/07/21 09:40:41 @@ -11,4 +11,5 @@ public boolean nested_scopes; + public String encoding; } Index: org/python/core/Py.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/Py.java,v retrieving revision 2.49 diff -u -r2.49 Py.java --- org/python/core/Py.java 2001/07/19 07:49:50 2.49 +++ org/python/core/Py.java 2001/07/21 09:40:44 @@ -1516,7 +1516,7 @@ public static PyCode compile_flags(InputStream istream, String filename, String type,CompilerFlags cflags) { - SimpleNode node = parser.parse(istream, type, filename); + SimpleNode node = parser.parse(istream, type, filename, cflags); boolean printResults = false; if (type.equals("single")) printResults = true; Index: org/python/core/imp.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/imp.java,v retrieving revision 2.48 diff -u -r2.48 imp.java --- org/python/core/imp.java 2001/07/17 20:34:35 2.48 +++ org/python/core/imp.java 2001/07/21 09:40:46 @@ -120,7 +120,7 @@ filename = ""; org.python.parser.SimpleNode node = null; //*Forte* try { - node = parser.parse(fp, "exec", filename); + node = parser.parse(fp, "exec", filename, null); } finally { fp.close(); } Index: org/python/core/parser.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/parser.java,v retrieving revision 2.10 diff -u -r2.10 parser.java --- org/python/core/parser.java 2001/07/20 13:37:43 2.10 +++ org/python/core/parser.java 2001/07/21 09:40:47 @@ -67,11 +67,13 @@ public static Node parse(String string, String kind) { - return parse(new StringBufferInputStream(string), kind, ""); + return parse(new StringBufferInputStream(string), + kind, "", null); } + public static SimpleNode parse(InputStream istream, String kind, - String filename) + String filename, CompilerFlags cflags) { int nbytes; try { @@ -85,7 +87,16 @@ if (nbytes > 100000) nbytes = 100000; - Reader reader = new InputStreamReader(istream); + Reader reader = null; + try { + if (cflags.encoding != null) { + reader = new InputStreamReader(istream, cflags.encoding); + } + } catch (UnsupportedEncodingException exc) { ; } + if (reader == null) { + reader = new InputStreamReader(istream); + } + //if (Options.fixMacReaderBug); reader = new FixMacReaderBug(reader); @@ -129,19 +140,21 @@ } public static SimpleNode partialParse(String string, String kind, - String filename) + String filename, + CompilerFlags cflags) { SimpleNode node = null; //System.err.println(new PyString(string).__repr__().toString()); try { - node = parse(new StringBufferInputStream(string), kind, filename); + node = parse(new StringBufferInputStream(string), + kind, filename, cflags); } catch (PySyntaxError e) { //System.out.println("e: "+e.lineno+", "+e.column+", "+ // e.forceNewline); try { node = parse(new StringBufferInputStream(string+"\n"), - kind, filename); + kind, filename, cflags); } catch (PySyntaxError e1) { //System.out.println("e1: "+e1.lineno+", "+e1.column+ Index: org/python/modules/codeop.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/modules/codeop.java,v retrieving revision 2.5 diff -u -r2.5 codeop.java --- org/python/modules/codeop.java 2001/07/16 16:25:04 2.5 +++ org/python/modules/codeop.java 2001/07/21 09:40:47 @@ -35,7 +35,7 @@ public static PyObject compile_command_flags(String string,String filename,String kind,CompilerFlags cflags) { org.python.parser.SimpleNode node = - parser.partialParse(string+"\n", kind, filename); + parser.partialParse(string+"\n", kind, filename, cflags); if (node == null) return Py.None; Index: org/python/util/jython.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/util/jython.java,v retrieving revision 2.18 diff -u -r2.18 jython.java --- org/python/util/jython.java 2001/02/25 17:10:12 2.18 +++ org/python/util/jython.java 2001/07/21 09:40:48 @@ -18,6 +18,7 @@ "-jar jar : program read from __run__.py in jar file\n"+ "-c cmd : program passed in as string (terminates option list)\n"+ "-W arg : warning control (arg is action:message:category:module:lineno)\n"+ + "-E codec : Use a different codec the reading from the console.\n"+ "file : program read from script file\n"+ "- : program read from stdin (default; interactive mode if a "+ "tty)\n"+ @@ -179,6 +180,13 @@ } if (opts.interactive) { + if (opts.encoding == null) { + opts.encoding = PySystemState.registry.getProperty( + "python.console.encoding", null); + } + if (opts.encoding != null) { + interp.cflags.encoding = opts.encoding; + } try { interp.interact(null); } catch (Throwable t) { @@ -200,6 +208,7 @@ public java.util.Properties properties; public String command; public java.util.Vector warnoptions = new java.util.Vector(); + public String encoding; public CommandLineOptions() { filename = null; @@ -264,7 +273,9 @@ } else if (arg.equals("-W")) { warnoptions.addElement(args[++index]); - break; + } + else if (arg.equals("-E")) { + encoding = args[++index]; } else if (arg.startsWith("-D")) { String key = null;