【发布时间】:2021-04-09 19:38:46
【问题描述】:
我正在使用 pythran,一个 Python 到 c++ 的编译器 http://pythran.readthedocs.io/
在其手册页中,pythran says it supports the method write from TextIOWrapper
但是,试图编译这个简单的文件
文件:mylib.py
#pythran export write_test(str,bool)
#pythran export fake_write(str)
def write_test(fname,r):
if r:
print('writing %s'%fname)
f = open(fname,'w')
#write_line = f.writelines
write_line = f.write
else:
print('NO FILE WILL BE WRITTEN')
write_line = fake_write
for i in range(10):
write_line(str(i) + '\n')
if r:
f.close()
def fake_write(s):
return 0
使用命令行
pythran mylib.py -o mylib.so -O3 -march=native -v
消息失败:
mylib.py:9:21 错误:此对象的不支持属性“写入”
Pythran 版本:0.9.8.post2
Python 版本:3.8.5
使用 Ubuntu 20.04.1 LTS
【问题讨论】: