From 8d087644ca800b670df5477158ec656a27bf0cd4 Mon Sep 17 00:00:00 2001 From: walsoup Date: Wed, 10 Jun 2026 21:17:10 +0100 Subject: [PATCH 1/2] plistlib: fix TypeError when parsing partial ISO 8601 dates --- Lib/plistlib.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Lib/plistlib.py b/Lib/plistlib.py index 93f3ef5e38af843..c289c6419ad2abd 100644 --- a/Lib/plistlib.py +++ b/Lib/plistlib.py @@ -143,9 +143,17 @@ def _date_from_string(s, aware_datetime): lst = [] for key in order: val = gd[key] - if val is None: - break - lst.append(int(val)) + if val is not None: + lst.append(int(val)) + else: + # Fill missing components with defaults: month/day -> 1, hour/minute/second -> 0 + if key in ('month', 'day'): + lst.append(1) + elif key in ('hour', 'minute', 'second'): + lst.append(0) + else: + # Year should never be missing due to regex + raise ValueError("Missing year in date string") if aware_datetime: return datetime.datetime(*lst, tzinfo=datetime.UTC) return datetime.datetime(*lst) From 9285789d0b23a3325475a9192d95fd0abc3a7e93 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Wed, 10 Jun 2026 20:33:35 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2026-06-10-20-33-34.gh-issue-151221.gV-PqB.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2026-06-10-20-33-34.gh-issue-151221.gV-PqB.rst diff --git a/Misc/NEWS.d/next/Library/2026-06-10-20-33-34.gh-issue-151221.gV-PqB.rst b/Misc/NEWS.d/next/Library/2026-06-10-20-33-34.gh-issue-151221.gV-PqB.rst new file mode 100644 index 000000000000000..1392e628e5d8c08 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-06-10-20-33-34.gh-issue-151221.gV-PqB.rst @@ -0,0 +1 @@ +plistlib._date_from_string() was raising a confusing TypeError for partial ISO 8601 dates (e.g., '2024-06Z') because it broke early on missing components. The fix fills missing components with sensible defaults: month/day → 1, hour/minute/second → 0.