logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git
commit: f35b757c826027ab5263d431bbe363c6403bd66d
parent 45495228b7a6728b7e764bbcf1f38490cd3d8697
Author: dirkf <fieldhouse@gmx.net>
Date:   Sun, 19 Mar 2023 02:27:46 +0000

[utils] Ensure `allow_types` for `variadic()` is a tuple

Diffstat:

Mtest/test_utils.py1+
Myoutube_dl/utils.py2++
2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/test/test_utils.py b/test/test_utils.py @@ -1563,6 +1563,7 @@ Line 1 self.assertEqual(variadic(None), (None, )) self.assertEqual(variadic('spam'), ('spam', )) self.assertEqual(variadic('spam', allowed_types=dict), 'spam') + self.assertEqual(variadic('spam', allowed_types=[dict]), 'spam') def test_traverse_obj(self): _TEST_DATA = { diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py @@ -4213,6 +4213,8 @@ def multipart_encode(data, boundary=None): def variadic(x, allowed_types=(compat_str, bytes, dict)): + if not isinstance(allowed_types, tuple) and isinstance(allowed_types, compat_collections_abc.Iterable): + allowed_types = tuple(allowed_types) return x if isinstance(x, compat_collections_abc.Iterable) and not isinstance(x, allowed_types) else (x,)