Skip to content

Commit 3706675

Browse files
committed
fix python3 url quote error
1 parent 34f480c commit 3706675

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

example.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
redirect_uri=REDIRECT_URI)
1717

1818
try:
19-
print api.get_authorize_login_url(scope=("snsapi_login",))
20-
print api.exchange_code_for_access_token(code=code)
21-
except OAuth2AuthExchangeError, e:
22-
print e
19+
print(api.get_authorize_login_url(scope=("snsapi_login",)))
20+
print(api.exchange_code_for_access_token(code=code))
21+
except OAuth2AuthExchangeError as e:
22+
print(e)
2323

2424
auth_info = {
2525
'access_token': 'OezXcEiiBSKSxW0eoylIeGXVgVFIUy2pK5I7TVatC5MGtVqTIWjtyV5Pax8ZLiWw-NdEN9dPkEX8Yewsve2AktmzS0gmbvzRKO49l6sxHRfhXg1no5ObdGufYhRIubP2m3FUdv-Cop3t3S_xwMbBWQ',
@@ -28,11 +28,11 @@
2828
'expires_in': 7200,
2929
'scope': u'snsapi_login'}
3030

31-
print api.exchange_refresh_token_for_access_token(refresh_token=auth_info['refresh_token'])
31+
print(api.exchange_refresh_token_for_access_token(refresh_token=auth_info['refresh_token']))
3232

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

3535
r = api.user(openid=auth_info['openid'])
36-
print r
36+
print(r)
3737
v = api.validate_token(openid=auth_info['openid'])
38-
print v
38+
print(v)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
requirements = [l for l in f.read().splitlines() if l]
1111

1212
setup(name="python-weixin",
13-
version="0.4.5",
13+
version="0.4.6",
1414
description="Python Weixin API client support wechat-app",
1515
long_description=long_description,
1616
long_description_content_type="text/markdown",

weixin/helper.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ def url_quote(string, charset='utf-8', errors='strict', safe='/:', unsafe=''):
295295
safe = safe.encode(charset, errors)
296296
if isinstance(unsafe, text_type):
297297
unsafe = unsafe.encode(charset, errors)
298-
safe = frozenset(bytearray(safe) + _always_safe) - frozenset(bytearray(unsafe))
298+
always_safe = _always_safe.encode(charset, errors)
299+
safe = frozenset(bytearray(safe) + always_safe) - frozenset(bytearray(unsafe))
299300
rv = bytearray()
300301
for char in bytearray(string):
301302
if char in safe:

0 commit comments

Comments
 (0)