PageSourceSearch

https://snakify.org/static/js/checker.py?3c9fe09

js snakify.org collected 2026-10-01 12:32:35 UTC 1,408 bytes, 54 lines download raw bytes

1from browser import document as doc, window, alert
2import io
3import sys
4import traceback
5
6class BrythonException:
7    def __init__(self, msg):
8        self.exception_type = 'error'
9        self.line = None
10        self.exception_msg = msg
11
12class ExecutionResult:
13    def __init__(self, output, stderr, exception):
14        self.output = output
15        self.stderr = stderr
16        self.exception = exception
17
18
19def execute_python(source, input_data):
20    orig_stdin = sys.stdin
21    orig_stdout = sys.stdout
22    orig_stderr = sys.stderr
23
24    sys.stdin = io.StringIO(input_data)
25    sys.stdout = io.StringIO()
26    sys.stderr = io.StringIO()
27
28    try:
29        exec(source, {'__name__': '__main__'})
30    except Exception as exc:
31        traceback.print_exc(file=sys.stderr)
32    finally:
33        exec_stdout = sys.stdout
34        exec_stderr = sys.stderr
35
36        sys.stdin = orig_stdin
37        sys.stdout = orig_stdout
38        sys.stderr = orig_stderr
39    error_msg = exec_stderr.getvalue()
40    return {
41        'stdout': exec_stdout.getvalue(),
42        'stderr': 'runtime_error' if error_msg else '',
43        'exception': BrythonException(error_msg) if error_msg != '' else '',
44    }
45
46
47def run_test(user_code, test_input):
48    res = execute_python(user_code, test_input)
49    user_answer = res['stdout'].strip()
50
51    return ExecutionResult(user_answer, res['stderr'], res['exception'])
52
53
54window.run_test = run_test

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.