A feature-rich command-line audio/video downloader
[outtmpl] Do not traverse `None` Closes #1585
pukkandan582fad70f547
diff --git a/test/test_YoutubeDL.py b/test/test_YoutubeDL.pyindex bd2d752e25..40c4169c8b 100644--- a/test/test_YoutubeDL.py+++ b/test/test_YoutubeDL.py@@ -737,6 +737,7 @@ class TestYoutubeDL(unittest.TestCase):test(NA_TEST_OUTTMPL, 'NA-NA-def-1234.mp4')test(NA_TEST_OUTTMPL, 'none-none-def-1234.mp4', outtmpl_na_placeholder='none')test(NA_TEST_OUTTMPL, '--def-1234.mp4', outtmpl_na_placeholder='')+ test('%(non_existent.0)s', 'NA')# String formattingFMT_TEST_OUTTMPL = '%%(height)%s.%%(ext)s'diff --git a/yt_dlp/utils.py b/yt_dlp/utils.pyindex 75b4ed61b6..875ab5e729 100644--- a/yt_dlp/utils.py+++ b/yt_dlp/utils.py@@ -6442,10 +6442,10 @@ def traverse_obj(def _traverse_obj(obj, path, _current_depth=0):nonlocal depth- if obj is None:- return Nonepath = tuple(variadic(path))for i, key in enumerate(path):+ if obj is None:+ return Noneif isinstance(key, (list, tuple)):obj = [_traverse_obj(obj, sub_key, _current_depth) for sub_key in key]key = ...