| 8 | pass |
| 9 | |
| 10 | def run_single(self, program): |
| 11 | buffer = io.StringIO() # Create an in-memory buffer for the output |
| 12 | stdout = sys.stdout # Save the original standard output |
| 13 | sys.stdout = buffer # Redirect the standard output to the buffer |
| 14 | try: |
| 15 | exec(program) |
| 16 | except Exception as e: |
| 17 | # Handle the error here |
| 18 | error_message = str(e) |
| 19 | sys.stdout = stdout # Restore the original standard output |
| 20 | return error_message |
| 21 | |
| 22 | exec(program) |
| 23 | sys.stdout = stdout # Restore the original standard output |
| 24 | output = buffer.getvalue() # Get the output from the buffer |
| 25 | return output |
| 26 | |
| 27 | def run(self, snippet): |
| 28 | if snippet == None: |