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 support #47

Open
Daenyth opened this issue Mar 8, 2011 · 19 comments
Open

Python 3 support #47

Daenyth opened this issue Mar 8, 2011 · 19 comments
Assignees
Milestone

Comments

@Daenyth
Copy link

Daenyth commented Mar 8, 2011

Is there any roadmap for python 3 support? I have some scripts that I might like to convert to py3k soon but are using restkit. I may be able to help somewhat with the translation, but I'm not sure if I can properly dedicate the time. Since it's pure python (as far as I can tell), it shouldn't take much effort to make it compatible.

@benoitc
Copy link
Owner

benoitc commented Mar 19, 2011

Next release will be python3 compatible. Probably at the end of the month.

@benoitc
Copy link
Owner

benoitc commented Apr 25, 2011

ok, finally got most of the bits to port restkit to py3. restkit will use http-parser in next release which support py3. net restkit will be online in 1 or 2 weeks with python3 support and somme enhancements. This version will also drop support for py2.5 .

@ghost ghost assigned benoitc Apr 25, 2011
@gelendir
Copy link

Is there a status update on python 3 support ? I was thinking of hacking up a small program this weekend to learn python3 and was thinking of using restkit for REST stuff. (otherwise i'll just fall back to python2 and port when available)

@benoitc
Copy link
Owner

benoitc commented Jun 19, 2011

available in 021104a .

@gelendir
Copy link

I tried cloning 021104a and installing it, but when I import it in python3 there are a lot of errors. Exceptions still use python2 syntax and imported modules still use python2 names. Are you sure that's the right commit ?

@benoitc
Copy link
Owner

benoitc commented Jun 20, 2011

you can't just import you need toiinstall it or patch it manually with
2to3 . work in progress anyway.

  • benoit

On Monday, June 20, 2011, gelendir
[email protected]
wrote:

I tried cloning 021104a and installing it, but when I import it in python3 there are a lot of errors. Exceptions still use python2 syntax and imported modules still use python2 names. Are you sure that's the right commit ?

Reply to this email directly or view it on GitHub:
#47 (comment)

@rboulton
Copy link

Are you interested in using six (http://packages.python.org/six/) to make a version which doesn't need patching with 2to3? I've just done that for restpose-py, and it seemed a reasonable approach, though there may be harder issues to fix for restkit.

@rboulton
Copy link

Scratch that comment - I see that installing does the 2to3 conversion - clever, and cunning.

I can't get it to work yet, though (though it does import ok once installed); may be I'm calling it wrong.

@benoitc
Copy link
Owner

benoitc commented Jul 24, 2011

On Sunday, July 24, 2011, rboulton <
[email protected]>
wrote:

Scratch that comment - I see that installing does the 2to3 conversion -
clever, and cunning.

I can't get it to work yet, though (though it does import ok once
installed); may be I'm calling it wrong.

Reply to this email directly or view it on GitHub:
#47 (comment)

py3 version need some work. i'm currently refactoring the client to make it
happen.

  • benoit

@rboulton
Copy link

Cool - I look forward to testing it.

@gdamjan
Copy link

gdamjan commented Sep 11, 2011

seems to install fine with Python 3 (3.2.2 here), but a demo that tries OAuth fails with:

  File "/home/damjan/py/lib/python3.2/site-packages/restkit/__init__.py", line 107, in request
    headers=headers)
  File "/home/damjan/py/lib/python3.2/site-packages/restkit/client.py", line 450, in request
    ret = f.on_request(request)
  File "/home/damjan/py/lib/python3.2/site-packages/restkit/filters.py", line 95, in on_request
    oauth_req.sign_request(self.method, self.consumer, self.token)
  File "/home/damjan/py/lib/python3.2/site-packages/restkit/oauth2.py", line 472, in sign_request
    self['oauth_body_hash'] = base64.b64encode(sha(self.body).digest())
TypeError: Unicode-objects must be encoded before hashing

the code is :

consumer = oauth.Consumer(consumer_key, consumer_secret)
token = oauth.Token(oauth_token, oauth_token_secret)
auth = OAuthFilter("*", consumer, token)

req = request('https://userstream.twitter.com/2/user.json', filters=[auth])

@gdamjan
Copy link

gdamjan commented Sep 11, 2011

regarding the last exception, it seems to be created by several occurences of body='' which is not translated by 2to3.
Maybe it should be replaced with body=bytes() (or body=None, and then change it in the code).
bytes() is available in 2.6, 2.7 and 3.2, didn't check others.

@carlitux
Copy link

Hi, when will be ready py3 support?

@benoitc
Copy link
Owner

benoitc commented Feb 24, 2013

sometimes next week. i've most of the tests passing on a test branch here, but I need to do a small refactoring first.

@carlitux
Copy link

@benoitc thank you, if you need any help please let me know I am using restkit as base of one project.

@autopulated
Copy link

restkit seems to work in Python 3 if I run 2to3 manually, but when I install restkit from PyPI that doesn't happen – should it? (I don't see any 2to3 setup in setup.py)

@ari3s
Copy link

ari3s commented Jul 25, 2016

There is the 3 years old version of restkit on PyPI. Please, do you consider to finalize Python 3 version, and update PyPI?

@dniq
Copy link

dniq commented Jul 11, 2017

The py3 support actually only requires a few things to be done, it seems:

  1. Search cStringIO or StringIO import and replace with "from io import StringIO"
  2. Replace "import urlparse" with "from urllib.parse import urlparse"
  3. Ditto for import urlunparse, parse_qs and parse_qsl
  4. Search all "except" statements and replace comma with " as ".

Haven't actually tested this yet, but import is no longer failing :)

@akochepasov
Copy link

There is a pull request to support python 3. Just not finished.

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

No branches or pull requests

10 participants