summaryrefslogtreecommitdiff
path: root/yaksh/stdio_evaluator.py
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh/stdio_evaluator.py')
-rw-r--r--yaksh/stdio_evaluator.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/yaksh/stdio_evaluator.py b/yaksh/stdio_evaluator.py
index efb2ae5..7530b96 100644
--- a/yaksh/stdio_evaluator.py
+++ b/yaksh/stdio_evaluator.py
@@ -1,9 +1,10 @@
+from __future__ import unicode_literals
+
# Local imports
-from code_evaluator import CodeEvaluator
+from .code_evaluator import CodeEvaluator
class StdIOEvaluator(CodeEvaluator):
-
def setup(self):
super(StdIOEvaluator, self).setup()
pass
@@ -15,7 +16,10 @@ class StdIOEvaluator(CodeEvaluator):
def evaluate_stdio(self, user_answer, proc, expected_input, expected_output):
success = False
ip = expected_input.replace(",", " ")
- user_output, output_err = proc.communicate(input='{0}\n'.format(ip))
+ encoded_input = '{0}\n'.format(ip).encode('utf-8')
+ user_output_bytes, output_err_bytes = proc.communicate(encoded_input)
+ user_output = user_output_bytes.decode('utf-8')
+ output_err = output_err_bytes.decode('utf-8')
expected_output = expected_output.replace("\r", "")
if not expected_input:
error_msg = "Expected Output is {0} ".\
@@ -30,5 +34,5 @@ class StdIOEvaluator(CodeEvaluator):
err = " Incorrect answer\n" + error_msg +\
"\n Your output is {0}".format(repr(user_output))
else:
- err = "Error:"+"\n"+output_err
+ err = "Error:\n {0}".format(output_err)
return success, err