GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — ScriptEngine.eval(Reader)/compile(Reader) fails on scripts over ~97,800 characters -- is the fixed 100,000-char retry budget in parseExpressionOrModule intentional? · Issue #459 · jython/jython Open DescriptionEnvironment
Question
Was 100,000 chosen as "plenty for any script anyone would run through What I found (verified against source, not just bytecode)
private static int MARK_LIMIT = 100000; public static mod parseExpressionOrModule(Reader reader, String filename, CompilerFlags cflags) { ExpectedEncodingBufferedReader bufReader = null; try { bufReader = prepBufReader(reader, cflags, filename); // first, try parsing as an expression return parse(bufReader, CompileMode.eval, filename, cflags); } catch (Throwable t) { if (bufReader == null) { throw Py.JavaError(t); } try { // then, try parsing as a module bufReader.reset(); // <-- throws here once the failed expression parse read >100,000 chars return parse(bufReader, CompileMode.exec, filename, cflags); } catch (Throwable tt) { throw fixParseError(bufReader, tt, filename); } } } private static mod parse(ExpectedEncodingBufferedReader reader, CompileMode kind, String filename, CompilerFlags cflags) throws Throwable { reader.mark(MARK_LIMIT); // We need the ability to move back on the // reader, for the benefit of fixParseError and // validPartialSentence ... } I initially assumed this was related to the PEP-263 encoding-declaration Since every real script (anything with a statement, not just a bare Minimal reproductionimport javax.script.*; import java.io.*; public class TestJythonEval { public static void main(String[] args) throws Exception { ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine engine = mgr.getEngineByName("python"); try (Reader r = new BufferedReader(new FileReader(args[0]))) { ((Compilable) engine).compile(r); System.out.println("COMPILE OK"); } catch (ScriptException e) { System.out.println("SCRIPT EXCEPTION: " + e); } } } javac -cp jython-standalone-2.7.4.jar TestJythonEval.java # Any real script over ~100KB reproduces this; a plain comment-only file works too: python3 -c "open('big.py','w').write(('# ' + 'x'*76 + chr(10)) * 1300)" java -cp .:jython-standalone-2.7.4.jar TestJythonEval big.py # -> SCRIPT EXCEPTION: javax.script.ScriptException: java.io.IOException: java.io.IOException: Mark invalid I bisected the exact threshold on one specific real-world script and found One more data pointThe same content loads without any error if it's AskIf the fixed 100,000-character retry budget is intentional: is there a ActivityMetadataMetadataAssigneesLabelsNo labels TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |