Skip to content

Python3 support - #51

Closed
hades wants to merge 4 commits into
joestump:masterfrom
hades:python3
Closed

hades wants to merge 4 commits into
joestump:masterfrom
hades:python3

Conversation

@hades

@hades hades commented Feb 10, 2011

Copy link
Copy Markdown

This adds support for Python3. All tests run successfully.

@zookos

zookos commented Feb 10, 2011

Copy link
Copy Markdown
Contributor

Hi! Thank you for the patch.

I'm not sure how to best take advantage of it, though, because I can't abandon support for Python 2, and I don't want to support two codebases.

Is it possible to make a single codebase that works in both Python 2 and Python 3, perhaps by using the six library? http://packages.python.org/six/

Regards,

Zooko

@hades

hades commented Feb 25, 2011

Copy link
Copy Markdown
Author

Uhm... I don't think six is a good idea. Can you, perhaps, just push it as a separate branch, so people know it is there? Or I can perhaps take over the support for python 3 variant until such time comes that no one needs python 2 anymore :)

@gorakhargosh

Copy link
Copy Markdown

I think a major portion of the library
will need to be refactored to make it
work with Python 3.

Using absolute imports may be useful.

Cheers.

osman and others added 2 commits August 12, 2011 14:46
the original port had both oauth_body_hash and oauth_signature as bytestrings. this caused the request to be sent out with those fields enclosed in b''. This caused POST requests to fail for me, not sure why GET requests worked.
make sure oauth headers are not bytestrings
@takluyver

Copy link
Copy Markdown

I'm willing to look into a Python 2 & 3 port. What's the minimum version of Python 2 which must be supported? The job gets substantially easier with only Python 2.6.

@gorakhargosh

Copy link
Copy Markdown

I've been writing one here at
https://github.com/gorakhargosh/pyoauth that
should work on Python 2 and 3 starting at
Python 2.5. However, due to the lack of time
these days, I've been unable to work on it
lately.

Have a look if you're interested.

Cheers, =)

@takluyver

Copy link
Copy Markdown

@gorakhargosh : I think it makes sense to focus on python-oauth2, because many people are already using it (going by PyPI download counts), and they'll be reluctant to port their code to another OAuth library in order to use Python 3.

Comment thread oauth2/__init__.py

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

list() shouldn't be needed here.

@takluyver

Copy link
Copy Markdown

So what would need doing to support Python 2 & 3 from one codebase? The options are roughly:

  • Have Python 2 source, and run 2to3 during setup for Python 3. Requires less initial effort, but testing is slowed down by the conversion step. Instructions here.
  • Use six or an equivalent abstraction layer to abstract away the differences. This mostly shouldn't be too hard, but catching some exceptions will become ugly, unless we can move the minimum Python version up to 2.6, which supports the new except Exception as e syntax. It looks like there's about a dozen cases of that, so it's not too bad if they have to be ugly. Abstracting u('Unicode strings) and b('byte strings') is also not very beautiful.

@joestump

Copy link
Copy Markdown
Owner

@jaitaiwan can you take a look at this? It's related to #158. @hades thanks for the PR! 🎉

@joestump joestump added the PY3K label Jul 29, 2015
@jaitaiwan

Copy link
Copy Markdown
Contributor

@joestump added to the list. I have a feeling that my PR doesn't use the futures lib... but I don't think any others do either. Will continue the chat in #158.

@jaitaiwan

Copy link
Copy Markdown
Contributor

This one fails to work in Pyk2 so I think we may drop it https://travis-ci.org/CentricWebEstate/python-oauth2/jobs/75874253

Thoughts @rickhanlonii @joestump?

@rickhanlonii

Copy link
Copy Markdown
Collaborator

Yeah, there are other pk3 wips that are farther along at this point. Thanks for the contribution @hades!

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants