python / python/cpython

sqlite3 command-line interface crashes on a NUL byte or lone surrogate in an input line

未关闭
#153,731 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

stdlib topic-sqlite3 type-bug
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

Bug description

The python -m sqlite3 interactive shell crashes with a traceback and exits
when an input line contains an embedded NUL byte, or a lone surrogate under a
surrogateescape stdin. sqlite3.complete_statement() raises ValueError
(embedded NUL) or UnicodeEncodeError (lone surrogate); neither is a
sqlite3.Error, so it escapes the REPL instead of being reported like an
ordinary error.

$ printf "SELECT '\0';\nSELECT 1;\n" | python -m sqlite3
sqlite> Traceback (most recent call last):
  ...
ValueError: embedded null character

The following SELECT 1; never runs. Invalid SQL and unknown dot-commands, by
contrast, print a clean error and keep the shell running.

CPython versions tested on

3.14, 3.15, 3.16

Operating systems tested on

macOS

Linked PRs
  • gh-153732

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先,通过交互式 shell python -m sqlite3 运行报告中的输入,并检查它如何调用 sqlite3.complete_statement()。当包含 NUL 字节和孤立 surrogate 的输入产生干净的错误,同时 shell 仍继续运行并处理后续语句时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
python, sqlite
领域
cli, databases
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。