Skip to content

Commit

Permalink
fix python3 url quote error
Browse files Browse the repository at this point in the history
  • Loading branch information
gusibi committed Dec 21, 2018
1 parent 34f480c commit 3706675
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
14 changes: 7 additions & 7 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
redirect_uri=REDIRECT_URI)

try:
print api.get_authorize_login_url(scope=("snsapi_login",))
print api.exchange_code_for_access_token(code=code)
except OAuth2AuthExchangeError, e:
print e
print(api.get_authorize_login_url(scope=("snsapi_login",)))
print(api.exchange_code_for_access_token(code=code))
except OAuth2AuthExchangeError as e:
print(e)

auth_info = {
'access_token': 'OezXcEiiBSKSxW0eoylIeGXVgVFIUy2pK5I7TVatC5MGtVqTIWjtyV5Pax8ZLiWw-NdEN9dPkEX8Yewsve2AktmzS0gmbvzRKO49l6sxHRfhXg1no5ObdGufYhRIubP2m3FUdv-Cop3t3S_xwMbBWQ',
Expand All @@ -28,11 +28,11 @@
'expires_in': 7200,
'scope': u'snsapi_login'}

print api.exchange_refresh_token_for_access_token(refresh_token=auth_info['refresh_token'])
print(api.exchange_refresh_token_for_access_token(refresh_token=auth_info['refresh_token']))

api = WeixinAPI(access_token=auth_info['access_token'])

r = api.user(openid=auth_info['openid'])
print r
print(r)
v = api.validate_token(openid=auth_info['openid'])
print v
print(v)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
requirements = [l for l in f.read().splitlines() if l]

setup(name="python-weixin",
version="0.4.5",
version="0.4.6",
description="Python Weixin API client support wechat-app",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
3 changes: 2 additions & 1 deletion weixin/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ def url_quote(string, charset='utf-8', errors='strict', safe='/:', unsafe=''):
safe = safe.encode(charset, errors)
if isinstance(unsafe, text_type):
unsafe = unsafe.encode(charset, errors)
safe = frozenset(bytearray(safe) + _always_safe) - frozenset(bytearray(unsafe))
always_safe = _always_safe.encode(charset, errors)
safe = frozenset(bytearray(safe) + always_safe) - frozenset(bytearray(unsafe))
rv = bytearray()
for char in bytearray(string):
if char in safe:
Expand Down

0 comments on commit 3706675

Please sign in to comment.