aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/compat
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2022-07-18 05:50:54 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2022-07-18 06:31:14 +0530
commit6929b41a216e20f0498cbd99880b17eab16777c9 (patch)
treeacbf7d1155c39cdd4ae1e3567b994ea8c69958cd /yt_dlp/compat
parent0b5583b112d418ba4d4eefcde1cd4d54ab95458a (diff)
downloadhypervideo-pre-6929b41a216e20f0498cbd99880b17eab16777c9.tar.lz
hypervideo-pre-6929b41a216e20f0498cbd99880b17eab16777c9.tar.xz
hypervideo-pre-6929b41a216e20f0498cbd99880b17eab16777c9.zip
Remove Python 3.6 support
Closes #3764
Diffstat (limited to 'yt_dlp/compat')
-rw-r--r--yt_dlp/compat/__init__.py4
-rw-r--r--yt_dlp/compat/_legacy.py12
-rw-r--r--yt_dlp/compat/asyncio.py23
-rw-r--r--yt_dlp/compat/re.py18
4 files changed, 10 insertions, 47 deletions
diff --git a/yt_dlp/compat/__init__.py b/yt_dlp/compat/__init__.py
index df1d4e671..6d85a6a1f 100644
--- a/yt_dlp/compat/__init__.py
+++ b/yt_dlp/compat/__init__.py
@@ -3,13 +3,12 @@ import sys
import warnings
import xml.etree.ElementTree as etree
-from . import re
from ._deprecated import * # noqa: F401, F403
from .compat_utils import passthrough_module
# XXX: Implement this the same way as other DeprecationWarnings without circular import
passthrough_module(__name__, '._legacy', callback=lambda attr: warnings.warn(
- DeprecationWarning(f'{__name__}.{attr} is deprecated'), stacklevel=2))
+ DeprecationWarning(f'{__name__}.{attr} is deprecated'), stacklevel=3))
# HTMLParseError has been deprecated in Python 3.3 and removed in
@@ -33,6 +32,7 @@ compat_os_name = os._name if os.name == 'java' else os.name
if compat_os_name == 'nt':
def compat_shlex_quote(s):
+ import re
return s if re.match(r'^[-_\w./]+$', s) else '"%s"' % s.replace('"', '\\"')
else:
from shlex import quote as compat_shlex_quote # noqa: F401
diff --git a/yt_dlp/compat/_legacy.py b/yt_dlp/compat/_legacy.py
index e75f79bbf..09259c988 100644
--- a/yt_dlp/compat/_legacy.py
+++ b/yt_dlp/compat/_legacy.py
@@ -22,10 +22,14 @@ import urllib.request
import xml.etree.ElementTree as etree
from subprocess import DEVNULL
-from .compat_utils import passthrough_module # isort: split
-from .asyncio import run as compat_asyncio_run # noqa: F401
-from .re import Pattern as compat_Pattern # noqa: F401
-from .re import match as compat_Match # noqa: F401
+# isort: split
+import asyncio # noqa: F401
+import re # noqa: F401
+from asyncio import run as compat_asyncio_run # noqa: F401
+from re import Pattern as compat_Pattern # noqa: F401
+from re import match as compat_Match # noqa: F401
+
+from .compat_utils import passthrough_module
from ..dependencies import Cryptodome_AES as compat_pycrypto_AES # noqa: F401
from ..dependencies import brotli as compat_brotli # noqa: F401
from ..dependencies import websockets as compat_websockets # noqa: F401
diff --git a/yt_dlp/compat/asyncio.py b/yt_dlp/compat/asyncio.py
deleted file mode 100644
index c61e5c8fd..000000000
--- a/yt_dlp/compat/asyncio.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# flake8: noqa: F405
-from asyncio import * # noqa: F403
-
-from .compat_utils import passthrough_module
-
-passthrough_module(__name__, 'asyncio')
-del passthrough_module
-
-try:
- run # >= 3.7
-except NameError:
- def run(coro):
- try:
- loop = get_event_loop()
- except RuntimeError:
- loop = new_event_loop()
- set_event_loop(loop)
- loop.run_until_complete(coro)
-
-try:
- all_tasks # >= 3.7
-except NameError:
- all_tasks = Task.all_tasks
diff --git a/yt_dlp/compat/re.py b/yt_dlp/compat/re.py
deleted file mode 100644
index e1d3a2645..000000000
--- a/yt_dlp/compat/re.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# flake8: noqa: F405
-from re import * # F403
-
-from .compat_utils import passthrough_module
-
-passthrough_module(__name__, 're')
-del passthrough_module
-
-try:
- Pattern # >= 3.7
-except NameError:
- Pattern = type(compile(''))
-
-
-try:
- Match # >= 3.7
-except NameError:
- Match = type(compile('').match(''))