Skip to content
Snippets Groups Projects
Commit e703661c authored by buczekp's avatar buczekp
Browse files

[LMS-1979] minor: removed dead code

SVN: 20280
parent 720493ba
No related branches found
No related tags found
No related merge requests found
......@@ -105,7 +105,7 @@ public final class Evaluator
}
this.interpreter = new PythonInterpreter();
// Security: do not allow file access.
try
{
interpreter.exec("def open():\n pass");
......@@ -133,11 +133,11 @@ public final class Evaluator
PyObject pyObject = interpreter.get(functionName);
return pyObject instanceof PyFunction;
}
/**
* Evaluates specified function with specified arguments. The arguments are turned into
* Python Strings if they are Java {@link String} objects. The return value of the function
* is returned as a Java object or <code>null</code>.
* Evaluates specified function with specified arguments. The arguments are turned into Python
* Strings if they are Java {@link String} objects. The return value of the function is returned
* as a Java object or <code>null</code>.
*
* @throws EvaluatorException if evaluation fails.
*/
......@@ -166,7 +166,7 @@ public final class Evaluator
} catch (PyException ex)
{
StringBuilder builder = new StringBuilder();
for (Object argument : args)
for (Object argument : args)
{
if (builder.length() > 0)
{
......@@ -203,34 +203,6 @@ public final class Evaluator
}
}
/**
* @throws EvaluatorException if compilation of given expression fails
*/
public static void checkExpressionCompilation(String expression) throws EvaluatorException
{
new PythonInterpreter();
doCompile(expression);
}
/**
* @throws EvaluatorException if compilation of given script fails
*/
public static void checkScriptCompilation(String script) throws EvaluatorException
{
try
{
PythonInterpreter pi = new PythonInterpreter();
// Security: do not allow file access.
pi.exec("def open():\n pass");
pi.exec(script);
} catch (PyException ex)
{
final String msg =
"Script compilation failed with message:\n\n" + extractExceptionMessage(ex);
throw new EvaluatorException(msg);
}
}
/**
* Sets the variable <var>name</var> to <var>value</var> in the evaluator's name space.
*/
......
......@@ -338,19 +338,4 @@ public class EvaluatorTest extends AssertJUnit
}
}
@Test
public void testCheckScriptCompilation()
{
Evaluator.checkScriptCompilation("1+1");
try
{
Evaluator.checkScriptCompilation("1+");
fail("EvaluatorException expected");
} catch (EvaluatorException ex)
{
assertEquals("Script compilation failed with message:\n\n"
+ "SyntaxError: ('invalid syntax', ('<string>', 1, 3, '1+'))", ex.getMessage());
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment