mirror of
https://github.com/yt-dlp/yt-dlp
synced 2026-01-16 11:04:46 -05:00
[utils] devalue: Fix calling reviver on cached value (#15568)
Authored by: Grub4K
This commit is contained in:
@@ -227,9 +227,13 @@ class TestDevalue(unittest.TestCase):
|
||||
{'a': 'b'}, 'revivers (indirect)')
|
||||
|
||||
self.assertEqual(
|
||||
devalue.parse([['parse', 1], '{"a":0}'], revivers={'parse': lambda x: json.loads(x)}),
|
||||
devalue.parse([['parse', 1], '{"a":0}'], revivers={'parse': json.loads}),
|
||||
{'a': 0}, 'revivers (parse)')
|
||||
|
||||
self.assertEqual(
|
||||
devalue.parse([{'a': 1, 'b': 3}, ['EmptyRef', 2], 'false', ['EmptyRef', 2]], revivers={'EmptyRef': json.loads}),
|
||||
{'a': False, 'b': False}, msg='revivers (duplicate EmptyRef)')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
@@ -62,10 +62,10 @@ def parse_iter(parsed: typing.Any, /, *, revivers: dict[str, collections.abc.Cal
|
||||
if isinstance(source, tuple):
|
||||
name, source, reviver = source
|
||||
try:
|
||||
resolved[source] = target[index] = reviver(target[index])
|
||||
target[index] = reviver(target[index])
|
||||
except Exception as error:
|
||||
yield TypeError(f'failed to parse {source} as {name!r}: {error}')
|
||||
resolved[source] = target[index] = None
|
||||
target[index] = None
|
||||
continue
|
||||
|
||||
if source in resolved:
|
||||
|
||||
Reference in New Issue
Block a user