Apache Thrift Python 3支持

Rti*_*k88 7 python thrift python-3.x

我用以下方法编译了我的test.thrift文件:

thrift -gen py test.thrift
Run Code Online (Sandbox Code Playgroud)

然后我尝试导入创建的文件:

from test.ttypes import *
Run Code Online (Sandbox Code Playgroud)

当我使用Python 2.7时,导入工作,但是使用Python 3.4,它会引发

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/art/SerTest/addressThrift/gen-py/test/ttypes.py", line11, in <module>
from thrift.transport import TTransport
File "/usr/local/lib/python3.4/dist-
packages/thrift/transport/TTransport.py", line 20, in <module>  
from cStringIO import StringIO
ImportError: No module named 'cStringIO'
Run Code Online (Sandbox Code Playgroud)

我试图运行: sudo python3 setup.py install 并且有许多例外,所有似乎都与python 2 vs 3问题有关.例如:

File "/usr/local/lib/python3.4/dist-
     packages/thrift/transport/TSSLSocket.py", line 99
except socket.error, e:
                   ^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)

我还有一个警告,似乎很重要:

/usr/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'use_2to3'
Run Code Online (Sandbox Code Playgroud)

谷歌搜索Thrift Python 3支持似乎是矛盾的.
那些说没有支持:
cql是否支持python 3?
https://issues.apache.org/jira/browse/THRIFT-1857
在这里我从子文本中理解它:
Thrift python 3.4 TypeError:字符串参数预期,得到'字节'
Python 3.4 TypeError:输入最多预期1参数,得到3
https://issues.apache.org/jira/browse/THRIFT-2096
那么Thrift是否支持Python 3.X?如果是这样,我错过了什么?

Woo*_*dog 7

有一个更好的解决方案.而不是等待官方的python 3支持,为什么不使用我们的thrift实现python?

https://github.com/eleme/thriftpy

它完全支持python 3,pypy和pypy3.