mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-01-07 17:16:08 +00:00
[utils] Ensure allow_types
for variadic()
is a tuple
This commit is contained in:
parent
45495228b7
commit
f35b757c82
|
@ -1563,6 +1563,7 @@ Line 1
|
||||||
self.assertEqual(variadic(None), (None, ))
|
self.assertEqual(variadic(None), (None, ))
|
||||||
self.assertEqual(variadic('spam'), ('spam', ))
|
self.assertEqual(variadic('spam'), ('spam', ))
|
||||||
self.assertEqual(variadic('spam', allowed_types=dict), 'spam')
|
self.assertEqual(variadic('spam', allowed_types=dict), 'spam')
|
||||||
|
self.assertEqual(variadic('spam', allowed_types=[dict]), 'spam')
|
||||||
|
|
||||||
def test_traverse_obj(self):
|
def test_traverse_obj(self):
|
||||||
_TEST_DATA = {
|
_TEST_DATA = {
|
||||||
|
|
|
@ -4213,6 +4213,8 @@ def multipart_encode(data, boundary=None):
|
||||||
|
|
||||||
|
|
||||||
def variadic(x, allowed_types=(compat_str, bytes, dict)):
|
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,)
|
return x if isinstance(x, compat_collections_abc.Iterable) and not isinstance(x, allowed_types) else (x,)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue