核验记录:15_stack_trace.txt

与教程配套的原始示例或核验资料,保留完整内容;其中真实用户目录已脱敏,运行范围以记录本身为准。

Traceback (most recent call last):
  File "15_stack_trace.py", line 9, in load_settings
    cfg = parse_config(text)
          ^^^^^^^^^^^^^^^^^^
  File "15_stack_trace.py", line 5, in parse_config
    return json.loads(text)
           ^^^^^^^^^^^^^^^^
  File "<用户目录>\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\Lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<用户目录>\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\Lib\json\decoder.py", line 338, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<用户目录>\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\Lib\json\decoder.py", line 354, in raw_decode
    obj, end = self.scan_once(s, idx)
               ^^^^^^^^^^^^^^^^^^^^^^
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 22 (char 21)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "15_stack_trace.py", line 18, in <module>
    main()
  File "15_stack_trace.py", line 15, in main
    return load_settings('{"model": "deepseek",}')     # 多了一个逗号
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "15_stack_trace.py", line 11, in load_settings
    raise RuntimeError("配置文件格式错误") from e   # 保留原始原因
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: 配置文件格式错误

最内层帧: load_settings 第 11 行
根因类型: JSONDecodeError

关联教程

继续浏览教程 返回知识 →返回顶部 ↑
本篇目录
教程图解100%
教程图解