[Jython-checkins] jython (2.5): #1536 fix NPE in org.python.jsr223.PyScriptEngine.

frank.wierzbicki jython-checkins at python.org
Tue Mar 20 02:46:19 CET 2012


http://hg.python.org/jython/rev/ea08bca49afb
changeset:   6420:ea08bca49afb
branch:      2.5
parent:      6418:278d9cb22f28
user:        Frank Wierzbicki <fwierzbicki at gmail.com>
date:        Mon Mar 19 18:45:46 2012 -0700
summary:
  #1536 fix NPE in org.python.jsr223.PyScriptEngine.

files:
  NEWS                                                 |   1 +
  src/org/python/core/ParserFacade.java                |   2 -
  tests/java/org/python/jsr223/ScriptEngineIOTest.java |  14 ++++++++-
  3 files changed, 13 insertions(+), 4 deletions(-)


diff --git a/NEWS b/NEWS
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@
 
 Jython 2.5.3b2
   Bugs Fixed
+    - [ 1536 ] NPE in org.python.jsr223.PyScriptEngine:187
     - [ 1829 ] test_socket.py failing on Ubuntu (Oneiric)
     - [ 1844 ] bad host returned by getsockname
 
diff --git a/src/org/python/core/ParserFacade.java b/src/org/python/core/ParserFacade.java
--- a/src/org/python/core/ParserFacade.java
+++ b/src/org/python/core/ParserFacade.java
@@ -129,8 +129,6 @@
             } catch (Throwable tt) {
                 throw fixParseError(bufReader, tt, filename);
             }
-        } finally {
-            close(bufReader);
         }
     }
 
diff --git a/tests/java/org/python/jsr223/ScriptEngineIOTest.java b/tests/java/org/python/jsr223/ScriptEngineIOTest.java
--- a/tests/java/org/python/jsr223/ScriptEngineIOTest.java
+++ b/tests/java/org/python/jsr223/ScriptEngineIOTest.java
@@ -88,11 +88,20 @@
 
     public void testEvalWithReader() throws ScriptException, FileNotFoundException
     {
+        //Check that multiple evals don't cause an NPE.
+        //See issue http://bugs.jython.org/issue1536
         final ScriptEngineManager manager = new ScriptEngineManager();
 
         final String engineType = "jython";
         final ScriptEngine engine = manager.getEngineByName(engineType);
 
+        final StringWriter stdout = new StringWriter();
+        final StringWriter stderr = new StringWriter();
+
+        engine.getContext().setWriter(stdout);
+        engine.getContext().setErrorWriter(stderr);
+
+
         final Bindings bindings = new SimpleBindings();
         bindings.put("firstLevelNodes", 10);
         bindings.put("secondLevelNodes", 5);
@@ -102,8 +111,9 @@
 
         final Reader dfsScript = new FileReader("tests/python/dfs.py");
 
-        for (int i = 1; i <= 10; i++)
+        for (int i = 1; i <= 10; i++) {
             engine.eval(dfsScript);
+            assertEquals(61, engine.get("result"));
+        }
     }
-
 }

-- 
Repository URL: http://hg.python.org/jython


More information about the Jython-checkins mailing list