]> jfr.im git - yt-dlp.git/commitdiff
[utils] `Popen`: Shim undocumented `text_mode` property
authorSimon Sawicki <redacted>
Thu, 23 Feb 2023 03:18:45 +0000 (04:18 +0100)
committerGitHub <redacted>
Thu, 23 Feb 2023 03:18:45 +0000 (04:18 +0100)
Fixes #6317

Authored by: Grub4K

yt_dlp/utils.py

index 994239897cd3e3a499e0e277e524bfd253aeec2a..4fe718bf07c6ceeead458f3ed3615397ef15b0a6 100644 (file)
@@ -879,6 +879,7 @@ def __init__(self, *args, env=None, text=False, **kwargs):
             env = os.environ.copy()
         self._fix_pyinstaller_ld_path(env)
 
+        self.__text_mode = kwargs.get('encoding') or kwargs.get('errors') or text or kwargs.get('universal_newlines')
         if text is True:
             kwargs['universal_newlines'] = True  # For 3.6 compatibility
             kwargs.setdefault('encoding', 'utf-8')
@@ -900,7 +901,7 @@ def kill(self, *, timeout=0):
     @classmethod
     def run(cls, *args, timeout=None, **kwargs):
         with cls(*args, **kwargs) as proc:
-            default = '' if proc.text_mode else b''
+            default = '' if proc.__text_mode else b''
             stdout, stderr = proc.communicate_or_kill(timeout=timeout)
             return stdout or default, stderr or default, proc.returncode