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

Python 3 and capstone #93

Closed
fenuks opened this issue Apr 10, 2014 · 4 comments
Closed

Python 3 and capstone #93

fenuks opened this issue Apr 10, 2014 · 4 comments

Comments

@fenuks
Copy link
Contributor

fenuks commented Apr 10, 2014

Hi,
it's great that such excellent library such capstone is available for Python, but there is problem with Python 3, since it doesn't supporting relative imports in contrary to Python 2.
So instead doing in __init__.py from capstone import Cs # other imports omitted for sake of clarity you can do it this way: from . import Cs. In my opinion it would be even better to remove module capstone.py file and move its contents directly to __init__.py. Other modules also need to be slighty corrected.
Beside that, in some distributions like Arch, python is symbolic link to python3 or to be exact to python3.4 so building bindings fails due to Python2-style prints. It can be easily fixed, e.g. in test.py prints are Python 3 friendly (except line 47 print to_hex(code), but you forgot to do from __future__ import print_function). If you want, I can fix these defects and create pull request.

@aquynh
Copy link
Collaborator

aquynh commented Apr 10, 2014

yes, Python 3 support is still lacking. if you can make the current Python
binding support Python 3 fully, please send a pull request.

thanks!

@aquynh
Copy link
Collaborator

aquynh commented Apr 10, 2014

btw, i dont believe that simply moving code around (to init.py) like
this can make current binding fully support Python 3.
is that really possible?

thanks.

On Fri, Apr 11, 2014 at 7:12 AM, Nguyen Anh Quynh aquynh@gmail.com wrote:

yes, Python 3 support is still lacking. if you can make the current Python
binding support Python 3 fully, please send a pull request.

thanks!

@fenuks
Copy link
Contributor Author

fenuks commented Apr 10, 2014

Almost. I already moved casptone.py to __init__.py, so the imports remain the same. Each cpu architecture file uses relative import so it need be changed (by simply adding . to its imports). Now I'm gonna test it, you use ctypes and it has some changes in Python3 which are not compatible with Python2.

@aquynh
Copy link
Collaborator

aquynh commented Apr 11, 2014

cool!

is it possible to support both Python2 & Python3 with the same code? would
be ideal to have that.

your work would be appreciated by lots of people i think.

thanks.

On Fri, Apr 11, 2014 at 7:19 AM, fenuks notifications@github.com wrote:

Almost. I already moved casptone.py to init.py, so the imports remain
the same. Each cpu architecture file uses relative import so it need be
changed (by simply adding . to its imports). Now I'm gonna test it, you use
ctypes and it has some changes in Python3 which are not compatible with
Python2.

Reply to this email directly or view it on GitHubhttps://github.com//issues/93#issuecomment-40154269
.

@aquynh aquynh closed this as completed May 8, 2014
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