420
449
output_stream, input_stream, error_stream = StringIO.StringIO(), StringIO.StringIO(self._stdin), StringIO.StringIO()
421
450
sys.stdout, sys.stdin, sys.stderr = output_stream, input_stream, error_stream
424
456
if type(function) == tuple:
425
457
# very hackish... exec can't be put into a lambda function!
427
459
exec(function[0], function[1])
432
463
sys.stdout, sys.stdin, sys.stderr = sys_stdout, sys_stdin, sys_stderr
435
468
sys.stdout, sys.stdin, sys.stderr = sys_stdout, sys_stdin, sys_stderr
437
470
self._current_filespace_copy.flush_all()
439
472
return {'result': result,
440
474
'stdout': output_stream.getvalue(),
441
475
'stderr': output_stream.getvalue(),
442
476
'modified_files': self._current_filespace_copy.get_modified_files()}