fix(client): show message if indentation error (#53986)

pull/53998/head
Oliver Eyton-Williams 2024-03-06 11:49:24 +01:00 committed by GitHub
parent f00b77446a
commit 78f7ceb47a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 5 deletions

View File

@ -143,20 +143,19 @@ input = __inputGen(${JSON.stringify(input ?? [])})
runPython(`from ast_helpers import Node as _Node`); runPython(`from ast_helpers import Node as _Node`);
// The tests need the user's code as a string, so we write it to the virtual // The tests need the user's code as a string, so we write it to the virtual
// filesystem. // filesystem...
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
pyodide.FS.writeFile('/user_code.py', code, { encoding: 'utf8' }); pyodide.FS.writeFile('/user_code.py', code, { encoding: 'utf8' });
// ...and then read it back into a variable so that they can evaluate it.
runPython(` runPython(`
with open("/user_code.py", "r") as f: with open("/user_code.py", "r") as f:
from ast import parse as _parse
_code = f.read() _code = f.read()
_tree = _parse(_code)
`); `);
// Evaluates the learner's code so that any variables they define are
// available to the test.
try { try {
// Evaluates the learner's code so that any variables they define are
// available to the test.
runPython(code); runPython(code);
} catch (e) { } catch (e) {
const err = e as PythonError; const err = e as PythonError;