小编Kos*_*lak的帖子

Python bug:输入提示中的null字节

我发现了

input('some\x00 text')
Run Code Online (Sandbox Code Playgroud)

将提示some而不是some text.

从消息来源,我发现这个函数使用C函数PyOS_Readline,它在NULL字节后忽略提示中的所有内容.

来自PyOS_StdioReadline(FILE *sys_stdin, FILE *sys_stdout, const char *prompt):

fprintf(stderr, "%s", prompt);
Run Code Online (Sandbox Code Playgroud)

https://github.com/python/cpython/blob/3.6/Python/bltinmodule.c#L1989 https://github.com/python/cpython/blob/3.6/Parser/myreadline.c#L251

这是一个错误还是有原因的?

问题:http://bugs.python.org/issue30431

python prompt input readline nul

10
推荐指数
1
解决办法
500
查看次数

标签 统计

input ×1

nul ×1

prompt ×1

python ×1

readline ×1