You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by rd...@apache.org on 2011/05/12 20:11:08 UTC
svn commit: r1102405 - in /pig/branches/branch-0.9: CHANGES.txt
src/org/apache/pig/scripting/BoundScript.java
src/org/apache/pig/scripting/jython/JythonScriptEngine.java
test/org/apache/pig/test/TestScriptLanguage.java
Author: rding
Date: Thu May 12 18:11:07 2011
New Revision: 1102405
URL: http://svn.apache.org/viewvc?rev=1102405&view=rev
Log:
PIG-2056: Jython error messages should show script name
Modified:
pig/branches/branch-0.9/CHANGES.txt
pig/branches/branch-0.9/src/org/apache/pig/scripting/BoundScript.java
pig/branches/branch-0.9/src/org/apache/pig/scripting/jython/JythonScriptEngine.java
pig/branches/branch-0.9/test/org/apache/pig/test/TestScriptLanguage.java
Modified: pig/branches/branch-0.9/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.9/CHANGES.txt?rev=1102405&r1=1102404&r2=1102405&view=diff
==============================================================================
--- pig/branches/branch-0.9/CHANGES.txt (original)
+++ pig/branches/branch-0.9/CHANGES.txt Thu May 12 18:11:07 2011
@@ -178,6 +178,8 @@ PIG-1696: Performance: Use System.arrayc
BUG FIXES
+PIG-2056: Jython error messages should show script name (rding)
+
PIG-2014: SAMPLE shouldn't be pushed up (dvryaboy)
PIG-2058: Macro missing returns clause doesn't give a good error message (rding)
Modified: pig/branches/branch-0.9/src/org/apache/pig/scripting/BoundScript.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.9/src/org/apache/pig/scripting/BoundScript.java?rev=1102405&r1=1102404&r2=1102405&view=diff
==============================================================================
--- pig/branches/branch-0.9/src/org/apache/pig/scripting/BoundScript.java (original)
+++ pig/branches/branch-0.9/src/org/apache/pig/scripting/BoundScript.java Thu May 12 18:11:07 2011
@@ -277,7 +277,7 @@ public class BoundScript {
try {
grunt.parseStopOnError(true);
} catch (ParseException e) {
- throw new IOException("Failed to parse script", e);
+ throw new IOException("Failed to parse script " + e.getMessage(), e);
}
pigServer.executeBatch();
return PigStats.get();
Modified: pig/branches/branch-0.9/src/org/apache/pig/scripting/jython/JythonScriptEngine.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.9/src/org/apache/pig/scripting/jython/JythonScriptEngine.java?rev=1102405&r1=1102404&r2=1102405&view=diff
==============================================================================
--- pig/branches/branch-0.9/src/org/apache/pig/scripting/jython/JythonScriptEngine.java (original)
+++ pig/branches/branch-0.9/src/org/apache/pig/scripting/jython/JythonScriptEngine.java Thu May 12 18:11:07 2011
@@ -91,7 +91,7 @@ public class JythonScriptEngine extends
InputStream is = getScriptAsStream(path);
try {
- execfile(is);
+ execfile(is, path);
filesLoaded.add(path);
} finally {
is.close();
@@ -99,9 +99,9 @@ public class JythonScriptEngine extends
}
}
- static void execfile(InputStream script) throws ExecException {
+ static void execfile(InputStream script, String path) throws ExecException {
try {
- interpreter.execfile(script);
+ interpreter.execfile(script, path);
} catch (PyException e) {
String message = "Python Error. "+e.toString();
throw new ExecException(message, 1121, e);
@@ -199,16 +199,15 @@ public class JythonScriptEngine extends
Interpreter.setMain(true);
FileInputStream fis = new FileInputStream(scriptFile);
try {
- load(fis);
+ load(fis, scriptFile);
} finally {
fis.close();
}
return getPigStatsMap();
}
-// @Override
- public void load(InputStream script) throws IOException {
- Interpreter.execfile(script);
+ public void load(InputStream script, String scriptFile) throws IOException {
+ Interpreter.execfile(script, scriptFile);
}
@Override
Modified: pig/branches/branch-0.9/test/org/apache/pig/test/TestScriptLanguage.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.9/test/org/apache/pig/test/TestScriptLanguage.java?rev=1102405&r1=1102404&r2=1102405&view=diff
==============================================================================
--- pig/branches/branch-0.9/test/org/apache/pig/test/TestScriptLanguage.java (original)
+++ pig/branches/branch-0.9/test/org/apache/pig/test/TestScriptLanguage.java Thu May 12 18:11:07 2011
@@ -483,4 +483,31 @@ public class TestScriptLanguage {
assertTrue(stats.getErrorCode() == 1121);
assertTrue(stats.getReturnCode() == PigRunner.ReturnCode.PIG_EXCEPTION);
}
+
+ @Test // PIG-2056
+ public void NegativeTest3() throws Exception {
+ String[] script = {
+ "#!/usr/bin/python",
+ "from org.apache.pig.scripting import Pig",
+ "P = Pig.compile(\"\"\"",
+ " #TEST PIG COMMENTS",
+ " A = load 'studenttab10k' as (name, age, gpa);",
+ " store A into 'CompileBindRun_2.out';\"\"\")",
+ "result = P.bind().runSingle()"
+ };
+
+ Util.createLocalInputFile( "testScript.py", script);
+
+ String[] args = { "-x", "local", "testScript.py"};
+ PigStats stats = PigRunner.run(args, null);
+ assertFalse(stats.isSuccessful());
+ assertTrue(stats.getErrorCode() == 1121);
+ assertTrue(stats.getReturnCode() == PigRunner.ReturnCode.PIG_EXCEPTION);
+
+ String expected = "Python Error. Traceback (most recent call last):\n" +
+ " File \"testScript.py\", line 7";
+
+ String msg = stats.getErrorMessage();
+ assertEquals(expected, msg.substring(0, expected.length()));
+ }
}