diff --git a/example.py b/example.py index bf28aa1..192fbf9 100644 --- a/example.py +++ b/example.py @@ -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', @@ -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) diff --git a/setup.py b/setup.py index ac57b76..a1d4c6c 100644 --- a/setup.py +++ b/setup.py @@ -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", diff --git a/weixin/helper.py b/weixin/helper.py index 5cba964..995b8ba 100644 --- a/weixin/helper.py +++ b/weixin/helper.py @@ -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: