From 573de1547027bf2d432729b7152032a4fd804537 Mon Sep 17 00:00:00 2001 From: doe1080 <98906116+doe1080@users.noreply.github.com> Date: Tue, 1 Dec 2026 10:35:10 +0900 Subject: [PATCH] [utils] `PagedList`: Fix empty slices (#17843) Authored by: doe1080 --- test/test_utils.py | 2 ++ yt_dlp/utils/_utils.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/test/test_utils.py b/test/test_utils.py index 2be4ec7320..b95c8cdae5 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -807,6 +807,8 @@ class TestUtil(unittest.TestCase): testPL(5, 2, (0, 3), [0, 1, 2]) testPL(5, 2, (1, 4), [1, 2, 3]) testPL(5, 2, (2, 99), [2, 3, 4]) + testPL(5, 2, (0, 0), []) + testPL(5, 2, (2, 1), []) testPL(5, 2, (20, 99), []) def test_read_batch_urls(self): diff --git a/yt_dlp/utils/_utils.py b/yt_dlp/utils/_utils.py index 3ed29bffd1..f176edba23 100644 --- a/yt_dlp/utils/_utils.py +++ b/yt_dlp/utils/_utils.py @@ -2337,6 +2337,8 @@ class PagedList: return page_results def getslice(self, start=0, end=None): + if end is not None and start >= end: + return [] return list(self._getslice(start, end)) def _getslice(self, start, end):