aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/compat/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'yt_dlp/compat/__init__.py')
-rw-r--r--yt_dlp/compat/__init__.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/yt_dlp/compat/__init__.py b/yt_dlp/compat/__init__.py
index 9f8e8c3e5..5d3db4b4c 100644
--- a/yt_dlp/compat/__init__.py
+++ b/yt_dlp/compat/__init__.py
@@ -3,25 +3,18 @@ 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
-try:
- passthrough_module(__name__, '._legacy', callback=lambda attr: warnings.warn(
- DeprecationWarning(f'{__name__}.{attr} is deprecated'), stacklevel=2))
- HAS_LEGACY = True
-except ModuleNotFoundError:
- # Keep working even without _legacy module
- HAS_LEGACY = False
-del passthrough_module
+passthrough_module(__name__, '._legacy', callback=lambda attr: warnings.warn(
+ DeprecationWarning(f'{__name__}.{attr} is deprecated'), stacklevel=3))
# HTMLParseError has been 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):
+class compat_HTMLParseError(ValueError):
pass
@@ -39,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
@@ -76,3 +70,9 @@ if compat_os_name in ('nt', 'ce'):
return userhome + path[i:]
else:
compat_expanduser = os.path.expanduser
+
+
+# NB: Add modules that are imported dynamically here so that PyInstaller can find them
+# See https://github.com/pyinstaller/pyinstaller-hooks-contrib/issues/438
+if False:
+ from . import _legacy # noqa: F401