需要在python中找到print或printf的源代码 [英] Need to find the source code for print or printf in python
问题描述
我正在做一些我不能完全谈论的事情.我只能说我是信息安全和计算机科学专业的学生.
I am working on something that I cannot entirely talk about. All I can say is that I am a student in Information Security and Computer Science.
我只需要更改 Python 深处某些东西的一些源代码.现在,我特别想更改内置打印函数中的源代码.不幸的是,我找不到它在 python 源代码文件中的任何地方定义.
I simply need to change some source code of something deep inside python. For now, I would specifically like to change source code inside the builtin print function. Unfortunately, I can't find it defined any where in the python source code files.
有什么想法吗?
非常感谢.
特别是这个问题旨在询问 Python 中的打印函数是否可以被其他东西覆盖.这是为了在 Python 解释器中植入后门.
Specifically the question intended to ask if the print function in Python could be overwritten with something else. This was intended as to plant a backdoor in the Python interpreter.
推荐答案
在 cpython 中,print
函数是用 C 实现的,而不是 Python.您可以在此处找到源代码,但您必须重新编译 cpython以使更改生效.
In cpython, the print
function is implemented in C, not Python. You can find the source code here, but you'll have to recompile cpython in order for changes to take effect.
要在 Python 中实现 print
,请查看 pypy 的版本.
For an implementation of print
in Python, have a look at pypy's version.
这篇关于需要在python中找到print或printf的源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!