From ac752723ba482eec641a1681f60b2c8f39968755 Mon Sep 17 00:00:00 2001 From: cobyfrombrooklyn-bot Date: Thu, 26 Feb 2026 06:39:14 -0500 Subject: [PATCH] Fix #33243: Move return out of finally block in niconico downloader Python 3.14 emits SyntaxWarning for 'return' in a 'finally' block. Move 'return success' after the try/finally to eliminate the warning while preserving identical behavior (success is always set before the finally block runs). Added test_niconico_downloader.py verifying no SyntaxWarning on import. --- test/test_niconico_downloader.py | 24 ++++++++++++++++++++++++ youtube_dl/downloader/niconico.py | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 test/test_niconico_downloader.py diff --git a/test/test_niconico_downloader.py b/test/test_niconico_downloader.py new file mode 100644 index 000000000..df93067fb --- /dev/null +++ b/test/test_niconico_downloader.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python +# coding: utf-8 +from __future__ import unicode_literals + +import subprocess +import sys +import unittest + + +class TestNiconicoDownloader(unittest.TestCase): + def test_no_syntax_warning_return_in_finally(self): + """Issue #33243: 'return' in a 'finally' block triggers SyntaxWarning in Python 3.14+""" + result = subprocess.run( + [sys.executable, '-W', 'error::SyntaxWarning', '-c', + 'from youtube_dl.downloader.niconico import NiconicoDmcFD'], + capture_output=True, text=True) + self.assertEqual( + result.returncode, 0, + 'Importing niconico downloader raised SyntaxWarning ' + '(return in finally block):\n' + result.stderr) + + +if __name__ == '__main__': + unittest.main() diff --git a/youtube_dl/downloader/niconico.py b/youtube_dl/downloader/niconico.py index 6392c9989..2240febf8 100644 --- a/youtube_dl/downloader/niconico.py +++ b/youtube_dl/downloader/niconico.py @@ -63,4 +63,4 @@ class NiconicoDmcFD(FileDownloader): with heartbeat_lock: timer[0].cancel() download_complete = True - return success + return success