中职学生看不懂英文报错。原来提交前用浏览器里的 Skulpt 拦语法错误,只弹一句 「第 N 行存在语法错误」——Skulpt 九成报的是 bad input / bad token,没有列号。 - 提交前的语法检查挪到服务端:/code/format 先用 CPython 编译一遍(只编译不执行), api 镜像加 python3-minimal(3.13,与判题机同版本,+17MB),前端删掉 Skulpt - 报错按规则表翻成中文(pythonError.ts),生产库 2695 条 Python 编译错误覆盖 99.7%; 提交前拦下的和判题回来的编译错误共用同一张卡片 - 编辑器里标红出错行和 ^ 指的位置 - 中文标点(历史编译错误的 22%)一键换成英文,跳过字符串和注释、处理 f 字符串花括号; 594 条里修好 593 条,经 tokenize 核对没有改到字符串内容;走编辑器事务,可 Ctrl+Z Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
039992dc86
commit
2a4405d2ea
16 files changed
+733
-100
No files matched your search
@@ -239,7 +239,8 @@ submissionRoutes.post("/code/format", requireAuth, async (c) => {
|
||||
return failure(
|
||||
c,
|
||||
error.kind === "syntax" ? 400 : 500,
|
||||
error.kind === "syntax" ? "format-error" : "format-tool-error",
|
||||
// syntax-error 的 message 是 CPython 的报错原文,前端拿去翻成中文
|
||||
error.kind === "syntax" ? "syntax-error" : "format-tool-error",
|
||||
error.message,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user