diff options
author | dirkf <[email protected]> | 2024-03-10 19:06:57 +0000 |
---|---|---|
committer | dirkf <[email protected]> | 2024-03-27 13:11:17 +0000 |
commit | 31a15a7c8dfc618e5090948e6b44d27911383d4b (patch) | |
tree | 4b33272aa0856ab7959de771aeff7cb16faa4c12 /youtube_dl | |
parent | 19dc10b986eeda47975a0e77e84df20ad3b59062 (diff) | |
download | youtube-dl-31a15a7c8dfc618e5090948e6b44d27911383d4b.tar.gz youtube-dl-31a15a7c8dfc618e5090948e6b44d27911383d4b.zip |
[compat] Simplify/fix compat_html_parser_HTMLParseError
Diffstat (limited to 'youtube_dl')
-rw-r--r-- | youtube_dl/compat.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/youtube_dl/compat.py b/youtube_dl/compat.py index 637f0d82c..75dff58f2 100644 --- a/youtube_dl/compat.py +++ b/youtube_dl/compat.py @@ -2421,23 +2421,20 @@ except ImportError: # Python 2 compat_urllib_request_urlretrieve = compat_urlretrieve try: + from HTMLParser import ( + HTMLParser as compat_HTMLParser, + HTMLParseError as compat_HTMLParseError) +except ImportError: # Python 3 from html.parser import HTMLParser as compat_HTMLParser -except ImportError: # Python 2 - from HTMLParser import HTMLParser as compat_HTMLParser -compat_html_parser_HTMLParser = compat_HTMLParser - -try: # Python 2 - from HTMLParser import HTMLParseError as compat_HTMLParseError -except ImportError: # Python <3.4 try: from html.parser import HTMLParseError as compat_HTMLParseError except ImportError: # Python >3.4 - - # HTMLParseError has been deprecated in Python 3.3 and removed in + # HTMLParseError was deprecated in Python 3.3 and removed in # Python 3.5. Introducing dummy exception for Python >3.5 for compatible # and uniform cross-version exception handling class compat_HTMLParseError(Exception): pass +compat_html_parser_HTMLParser = compat_HTMLParser compat_html_parser_HTMLParseError = compat_HTMLParseError try: |