summaryrefslogtreecommitdiff
path: root/oauthlib/oauth1/rfc5849/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'oauthlib/oauth1/rfc5849/utils.py')
-rw-r--r--oauthlib/oauth1/rfc5849/utils.py15
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)