diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2015-02-01 11:30:56 +0100 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2015-02-01 11:30:56 +0100 |
commit | 8f9312c38779f4e0746c01ef9a8a93ab4767699b (patch) | |
tree | 7476dc54f00d0e334c2ba9ab1c7c3da4c99d3115 /youtube_dl/compat.py | |
parent | 439b9a9e9bbaa475fd5257cd0f42403be33e5788 (diff) |
Appease pyflakes8-3
Diffstat (limited to 'youtube_dl/compat.py')
-rw-r--r-- | youtube_dl/compat.py | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/youtube_dl/compat.py b/youtube_dl/compat.py index 497ca52de..ec685d50e 100644 --- a/youtube_dl/compat.py +++ b/youtube_dl/compat.py @@ -114,6 +114,26 @@ except ImportError: string += pct_sequence.decode(encoding, errors) return string +try: + compat_str = unicode # Python 2 +except NameError: + compat_str = str + +try: + compat_basestr = basestring # Python 2 +except NameError: + compat_basestr = str + +try: + compat_chr = unichr # Python 2 +except NameError: + compat_chr = chr + +try: + from xml.etree.ElementTree import ParseError as compat_xml_parse_error +except ImportError: # Python 2.6 + from xml.parsers.expat import ExpatError as compat_xml_parse_error + try: from urllib.parse import parse_qs as compat_parse_qs @@ -123,7 +143,7 @@ except ImportError: # Python 2 def _parse_qsl(qs, keep_blank_values=False, strict_parsing=False, encoding='utf-8', errors='replace'): - qs, _coerce_result = qs, unicode + qs, _coerce_result = qs, compat_str pairs = [s2 for s1 in qs.split('&') for s2 in s1.split(';')] r = [] for name_value in pairs: @@ -163,21 +183,6 @@ except ImportError: # Python 2 return parsed_result try: - compat_str = unicode # Python 2 -except NameError: - compat_str = str - -try: - compat_chr = unichr # Python 2 -except NameError: - compat_chr = chr - -try: - from xml.etree.ElementTree import ParseError as compat_xml_parse_error -except ImportError: # Python 2.6 - from xml.parsers.expat import ExpatError as compat_xml_parse_error - -try: from shlex import quote as shlex_quote except ImportError: # Python < 3.3 def shlex_quote(s): |