Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为什么不支持Python3 #1

Open
HatBoy opened this issue Jan 7, 2019 · 5 comments
Open

为什么不支持Python3 #1

HatBoy opened this issue Jan 7, 2019 · 5 comments

Comments

@HatBoy
Copy link

HatBoy commented Jan 7, 2019

请问为什么不支持Python3,是那些地方不兼容,如果改为兼容Python3需要修改哪些地方。另外请问该库绑定KCP是实现了KCP的所有函数还是只实现了部分函数

@xingshuo
Copy link
Owner

xingshuo commented Jan 8, 2019

目前只支持python2,因为python对象和c对象相互转换的python api接口(compat.h中)只封装了python2的,(当时生产环境只要求python2 - -!) 这个我有空支持下(就近期吧- -), post到python3环境还有要注意的就是各种三方库的变迁以及语言特性变更等。这个绑定实现了大部分生产环境能用到的kcp接口的python封装,如果能正常运行测试用例就可以投入生产中使用,具体使用方案请参考https://github.com/skywind3000/kcp

@HatBoy
Copy link
Author

HatBoy commented Jan 8, 2019

@xingshuo 查看了源码,了解到在compat.h里面做了强制的判断Python版本,于是将判断代码去掉,可编译通过安装,但是在运行例子时报错,主要原因是Python2中字符串可以当做字节流使用,而Python3将其分开了,所以如果要修改为兼容Python3主要是修改字符串和字节流的转换,目前开发和生产环境用的是Python3,急需将将该代码修改为兼容Python3,能力有限还望多指导,目前只是做了一些补充,将ikcp_peeksize和ikcp_setmtu、ikcp_waitsnd三个没有包装的函数包装了一下,使其更加完善

@xingshuo
Copy link
Owner

xingshuo commented Jan 8, 2019

这个我今晚(22点以后)回家处理下吧,人在公司,没有ubuntu环境,现在正在被老板催着改bug,晚上还要参加公司年会。。。

@HatBoy
Copy link
Author

HatBoy commented Jan 8, 2019

@xingshuo 我已经将该代码修改为Python3版本,主要是在kcp.py的send方法中对字符串数据进行编码,可编译安装并测试通过,刚接触KCP,不知道还会有哪些问题,望指导:https://github.com/HatBoy/Python-KCP ,另外,有空能否提供以UDP为下层协议的客户端和服务端实例代码,感激不尽,谢谢。

@xingshuo
Copy link
Owner

xingshuo commented Jan 8, 2019

ok,我有空搞个demo, 大家相互学习交流- -

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants