bbangert / velruse

Simplifying third-party authentication for web applications.
http://packages.python.org/velruse/index.html
MIT License
252 stars 86 forks source link

Fix python3 compatibility #123

Closed asabil closed 11 years ago

asabil commented 11 years ago

This branch fixes compatibility issues with python3 related to the usage of binaries instead of strings and also incorrect import for urlencode.

I was not able to fully test these changes against python2, and could not test all the affected providers. The only ones I tried were Facebook, Twitter and GoogleOAuth2.

mmerickel commented 11 years ago

Awesome! I'll try to find some time to test this soon.

zemlya25 commented 11 years ago

Hi, i've made almost the same changes for Python3 compatibility But I think it's better to use PY3 condition when you get response.content or response.text depends on python version . Otherwise in Python3 in ThirdPartyFailure exceptions you'll get byte array. And it's less readable.

asabil commented 11 years ago

response.text is generally what you want, if the payload received is text. I didn't change the ThirdPartyFailure failure exceptions, because I didn't know exactly how they were used. We should maybe also change them to use response.text instead of response.content?

zemlya25 commented 11 years ago

@asabil if response.text is the same with resp.content.decode(resp.encoding). We need to store correct data when different encoding used

Later i can check both solution on different env

zemlya25 commented 11 years ago

One more comment: in provider/vk.py this part of code will fail in PY3 due to iterated object could not be modified in for loop

def callback(self, request) ....

Now strip out empty values

for k, v in profile.items():
    if not v or (isinstance(v, list) and not v[0]):
        del profile[k]

,,,

need to change for smt like new_profile = {k:v for (k, v) in profile.items() if not ( not v or (isinstance(v, list) and not v[0]) ) } profile = new_profile