Repository: yt-dlp
Issue: yt_dlp Python: `write_string` TypeError: string argument expected, got 'bytes'
Labels: external issue

### DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

- [X] I understand that I will be **blocked** if I *intentionally* remove or skip any mandatory\* field

### Checklist

- [X] I'm reporting a bug unrelated to a specific site
- [X] I've verified that I have **updated yt-dlp to nightly or master** ([update instructions](https://github.com/yt-dlp/yt-dlp#update-channels))
- [X] I've checked that all provided URLs are playable in a browser with the same IP and same login details
- [X] I've checked that all URLs and arguments with special characters are [properly quoted or escaped](https://github.com/yt-dlp/yt-dlp/wiki/FAQ#video-url-contains-an-ampersand--and-im-getting-some-strange-output-1-2839-or-v-is-not-recognized-as-an-internal-or-external-command)
- [X] I've searched [known issues](https://github.com/yt-dlp/yt-dlp/issues/3766) and the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues **including closed ones**. DO NOT post duplicates
- [X] I've read the [guidelines for opening an issue](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#opening-an-issue)

### Provide a description that is worded well enough to be understood

Running latest yt_dlp library in Python3.12, suddenly getting this error. Never faced this issue before, and there has been no code changes. As you can see in the traceback, I am passing in a youtube link as a String list to ydl.download.

### Provide verbose output that clearly demonstrates the problem

- [X] Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
- [X] If using API, add `'verbose': True` to `YoutubeDL` params instead
- [X] Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below

### Complete Verbose Output

```shell
Traceback (most recent call last):
  File "/workspace/all_functions/getCaptionsPython.py", line 327, in run_ydl_get_captions
    ydl.download(['https://www.youtube.com/watch?v=KkCXLABwHP0'])
  File "/layers/google.python.pip/pip/lib/python3.12/site-packages/yt_dlp/YoutubeDL.py", line 3583, in download
    self.__download_wrapper(self.extract_info)(
  File "/layers/google.python.pip/pip/lib/python3.12/site-packages/yt_dlp/YoutubeDL.py", line 3558, in wrapper
    res = func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^
  File "/layers/google.python.pip/pip/lib/python3.12/site-packages/yt_dlp/YoutubeDL.py", line 1595, in extract_info
    return self.__extract_info(url, self.get_info_extractor(key), download, extra_info, process)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/layers/google.python.pip/pip/lib/python3.12/site-packages/yt_dlp/YoutubeDL.py", line 1606, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/layers/google.python.pip/pip/lib/python3.12/site-packages/yt_dlp/YoutubeDL.py", line 1741, in __extract_info
    ie_result = ie.extract(url)
                ^^^^^^^^^^^^^^^
  File "/layers/google.python.pip/pip/lib/python3.12/site-packages/yt_dlp/extractor/common.py", line 732, in extract
    self.to_screen('Extracting URL: %s' % (
  File "/layers/google.python.pip/pip/lib/python3.12/site-packages/yt_dlp/extractor/common.py", line 1200, in to_screen
    self._downloader.to_screen(f'[{self.IE_NAME}] {msg}', *args, **kwargs)
  File "/layers/google.python.pip/pip/lib/python3.12/site-packages/yt_dlp/YoutubeDL.py", line 924, in to_screen
    self._write_string(
  File "/layers/google.python.pip/pip/lib/python3.12/site-packages/yt_dlp/YoutubeDL.py", line 905, in _write_string
    write_string(message, out=out, encoding=self.params.get('encoding'))
  File "/layers/google.python.pip/pip/lib/python3.12/site-packages/yt_dlp/utils/_utils.py", line 1441, in write_string
    buffer.write(s.encode(enc, 'ignore') if enc else s)
TypeError: string argument expected, got 'bytes'
```