feat(题目): 运行时错误告诉学生第几行、为什么出错(Python 看回溯,C 看信号),不泄露测试数据
原来学生只看到「运行时错误」四个字:主判题 output: false,Python 回溯没回来; C 的信号值在 info 里,而 info 只给管理员。 - Python 判出 RE 时,拿第一个失败测试点单独重跑一次(内联测试点 + output: true), 从回溯取行号(扣掉模板前置行)、异常类型和按句式归的类别。主判题仍不开 output, 免得每个点最多 16MB 的输出回到 worker - C / C++ 取失败点的信号和退出码(段错误提示 scanf 漏 &、return 非 0 等) - 写进 statistic_info.runtime_error;不存异常原文(里面常带测试点输入),名字只在 出现在学生代码里时才存——raise Exception(input()) 实测只落下类型 - 前端按类型翻成中文、摆出出错那行并在编辑器标红;比赛提交不诊断(ACM 只报对错) - 没有诊断的 RE 不再说「代码格式写错了」 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2a4405d2ea
commit
db70ab62e8
7 files changed
+391
-11
No files matched your search
@@ -77,6 +77,30 @@ export const statisticInfoSchema = z.looseObject({
|
||||
}),
|
||||
)
|
||||
.optional(),
|
||||
/**
|
||||
* 运行时错误的诊断,judge/runtime-diagnosis.ts 写,前端翻成中文。只在非比赛提交上有。
|
||||
*
|
||||
* **不存异常的原文消息**:Python 的消息里常带着测试点的输入(`invalid literal for
|
||||
* int() with base 10: '1 2'`),给学生看就等于放出隐藏数据。所以只存归好类的
|
||||
* `kind`,和确实出现在学生自己代码里的名字。
|
||||
*/
|
||||
runtime_error: z
|
||||
.object({
|
||||
/** 学生代码里的行号(已经扣掉题目模板的前置代码),对不上时为 null */
|
||||
line: z.number().int().nullable().optional(),
|
||||
/** Python 异常类型,如 ValueError */
|
||||
type: z.string().optional(),
|
||||
/** 细分,如 int-parse / index / str-concat,见 runtime-diagnosis.ts 的 KINDS */
|
||||
kind: z.string().optional(),
|
||||
/** NameError / AttributeError 点名的那个名字,只在它出现在学生代码里时才存 */
|
||||
name: z.string().optional(),
|
||||
/** NameError 的「Did you mean」,Python 从作用域里的名字挑的,不来自输入 */
|
||||
suggestion: z.string().optional(),
|
||||
/** C / C++:进程收到的信号(11 段错误、8 除零……)和退出码 */
|
||||
signal: z.number().int().optional(),
|
||||
exit_code: z.number().int().optional(),
|
||||
})
|
||||
.optional(),
|
||||
})
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user