diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-08-03 17:47:38 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-08-03 17:48:59 +0530 |
commit | fe0918bb65c828ec81ce904cece58d450c117eba (patch) | |
tree | c36e7f7404f8bb2629e765c626e59c3d28f8d88a /yt_dlp/utils.py | |
parent | b99ba3df096cd9c2973f7cf978c58ccfb3fa2200 (diff) | |
download | hypervideo-pre-fe0918bb65c828ec81ce904cece58d450c117eba.tar.lz hypervideo-pre-fe0918bb65c828ec81ce904cece58d450c117eba.tar.xz hypervideo-pre-fe0918bb65c828ec81ce904cece58d450c117eba.zip |
Import ctypes only when necessary
Closes #4541
Diffstat (limited to 'yt_dlp/utils.py')
-rw-r--r-- | yt_dlp/utils.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index c0d9c6f79..c3ccb3a78 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -6,7 +6,6 @@ import calendar import codecs import collections import contextlib -import ctypes import datetime import email.header import email.utils @@ -1983,6 +1982,7 @@ class LockingUnsupportedError(OSError): # Cross-platform file locking if sys.platform == 'win32': + import ctypes import ctypes.wintypes import msvcrt @@ -2362,9 +2362,10 @@ def fix_xml_ampersands(xml_str): def setproctitle(title): assert isinstance(title, str) - # ctypes in Jython is not complete - # http://bugs.jython.org/issue2148 - if sys.platform.startswith('java'): + # Workaround for https://github.com/yt-dlp/yt-dlp/issues/4541 + try: + import ctypes + except ImportError: return try: |