这个问题是我之前的问题的后续问题,我尝试为 Python3 编译 python-yenc。在被告知没有快速解决方案后,我决定接受挑战并完全重写它。
我唯一不知道的是如何PyArg_ParseTupleAndKeywords
与 io-objects 一起使用。以下是相关代码:
PyObject *in_file, *out_file;
static char *kwlist[] = { "infile", "outfile", NULL };
if(!PyArg_ParseTupleAndKeywords(args, kwds, "O!O!|l", kwlist,\
&PyBytes_Type, &in_file,\
&PyBytes_Type, &out_file,\
&bytes)) return NULL;
这显然会产生
Traceback (most recent call last):
File "test.py", line 21, in <module>
print(_yenc.decode_file(b), outfile=o)
TypeError: argument 1 must be bytes, not _io.BufferedReader
如何将_io.BufferedReader
-objects 传递给我的函数?
谢谢,马丁