|
55 | 55 | import string
|
56 | 56 | from unicodedata import normalize
|
57 | 57 |
|
58 |
| -unicode = str |
59 |
| - |
60 | 58 | # The unreserved URI characters (per RFC 3986 Section 2.3)
|
61 | 59 | _UNRESERVED_CHARS = frozenset('~-._0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
62 | 60 | 'abcdefghijklmnopqrstuvwxyz')
|
@@ -124,9 +122,9 @@ class URLParseError(ValueError):
|
124 | 122 |
|
125 | 123 | def to_unicode(obj):
|
126 | 124 | try:
|
127 |
| - return unicode(obj) |
| 125 | + return str(obj) |
128 | 126 | except UnicodeDecodeError:
|
129 |
| - return unicode(obj, encoding=DEFAULT_ENCODING) |
| 127 | + return str(obj, encoding=DEFAULT_ENCODING) |
130 | 128 |
|
131 | 129 |
|
132 | 130 | # regex from gruber via tornado
|
@@ -174,7 +172,7 @@ def find_all_links(text, with_text=False, default_scheme='https', schemes=()):
|
174 | 172 | _add = ret.append
|
175 | 173 |
|
176 | 174 | def _add_text(t):
|
177 |
| - if ret and isinstance(ret[-1], unicode): |
| 175 | + if ret and isinstance(ret[-1], str): |
178 | 176 | ret[-1] += t
|
179 | 177 | else:
|
180 | 178 | _add(t)
|
@@ -311,7 +309,7 @@ def unquote_to_bytes(string):
|
311 | 309 | # Is it a string-like object?
|
312 | 310 | string.split
|
313 | 311 | return b''
|
314 |
| - if isinstance(string, unicode): |
| 312 | + if isinstance(string, str): |
315 | 313 | string = string.encode('utf-8')
|
316 | 314 | bits = string.split(b'%')
|
317 | 315 | if len(bits) == 1:
|
@@ -741,7 +739,7 @@ def get_authority(self, full_quote=False, with_userinfo=False):
|
741 | 739 | # TODO: 0 port?
|
742 | 740 | if self.port and self.port != self.default_port:
|
743 | 741 | _add(':')
|
744 |
| - _add(unicode(self.port)) |
| 742 | + _add(str(self.port)) |
745 | 743 | return ''.join(parts)
|
746 | 744 |
|
747 | 745 | def to_text(self, full_quote=False):
|
@@ -903,7 +901,7 @@ def parse_url(url_text):
|
903 | 901 | >>> sorted(res.keys()) # res is a basic dictionary
|
904 | 902 | ['_netloc_sep', 'authority', 'family', 'fragment', 'host', 'password', 'path', 'port', 'query', 'scheme', 'username']
|
905 | 903 | """
|
906 |
| - url_text = unicode(url_text) |
| 904 | + url_text = str(url_text) |
907 | 905 | # raise TypeError('parse_url expected text, not %r' % url_str)
|
908 | 906 | um = _URL_RE.match(url_text)
|
909 | 907 | try:
|
|
0 commit comments