diff options
author | Jonathan Huot <JonathanHuot@users.noreply.github.com> | 2019-08-30 11:56:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-30 11:56:43 +0200 |
commit | ca57b0bcae835493d9db8f9bf1f1228b71b8e3f8 (patch) | |
tree | 71f3d2ecee2ffd32da6f030558d0eed91d953895 /oauthlib/oauth1/rfc5849/utils.py | |
parent | 1f3fc4bfd4fd51711798186591bf3e3ba5a894be (diff) | |
parent | 11bf0eca2857f5330237e574630dd916d53cd573 (diff) | |
download | oauthlib-ca57b0bcae835493d9db8f9bf1f1228b71b8e3f8.tar.gz |
Merge pull request #700 from hugovk/rm-2.7
Drop support for Python 2.7
Diffstat (limited to 'oauthlib/oauth1/rfc5849/utils.py')
-rw-r--r-- | oauthlib/oauth1/rfc5849/utils.py | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/oauthlib/oauth1/rfc5849/utils.py b/oauthlib/oauth1/rfc5849/utils.py index 735f21d..28e006a 100644 --- a/oauthlib/oauth1/rfc5849/utils.py +++ b/oauthlib/oauth1/rfc5849/utils.py @@ -6,14 +6,9 @@ oauthlib.utils This module contains utility methods used by various parts of the OAuth spec. """ -from __future__ import absolute_import, unicode_literals +from oauthlib.common import quote, unquote -from oauthlib.common import quote, unicode_type, unquote - -try: - import urllib2 -except ImportError: - import urllib.request as urllib2 +import urllib.request as urllib2 UNICODE_ASCII_CHARACTER_SET = ('abcdefghijklmnopqrstuvwxyz' @@ -52,16 +47,16 @@ def escape(u): .. _`section 3.6`: https://tools.ietf.org/html/rfc5849#section-3.6 """ - if not isinstance(u, unicode_type): + if not isinstance(u, str): raise ValueError('Only unicode objects are escapable. ' + - 'Got %r of type %s.' % (u, type(u))) + 'Got {!r} of type {}.'.format(u, type(u))) # Letters, digits, and the characters '_.-' are already treated as safe # by urllib.quote(). We need to add '~' to fully support rfc5849. return quote(u, safe=b'~') def unescape(u): - if not isinstance(u, unicode_type): + if not isinstance(u, str): raise ValueError('Only unicode objects are unescapable.') return unquote(u) |