From 7287d26bc42bf853fbf69126bc4ea72eb66f5195 Mon Sep 17 00:00:00 2001 From: Mark Mentovai Date: Wed, 21 Oct 2026 14:08:28 -0400 Subject: [PATCH] =?UTF-8?q?Fix=20=5Fftp=5Fparse.=5Fparse=5Ftime=20for=20Py?= =?UTF-8?q?thon=20=E2=89=A5=C2=A03.15?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit time.strptime processing of formats that contain %d but not %Y was deprecated in Python 3.13, and removed from Python 3.15 (https://github.com/python/cpython/issues/70647). Deal with this by adding %Y and having it parse the current year, in line with prior semantics. This fixes these tests/test_ftp_parse.py TestFTPParse tests by restoring the ability to parse the '%b %d %H:%M' time format. - test_decode_linux - test_decode_linux_sticky - test_decode_linux_suid - test_parse_time --- fs/_ftp_parse.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/_ftp_parse.py b/fs/_ftp_parse.py index 16c581eb..d7ff5d5a 100644 --- a/fs/_ftp_parse.py +++ b/fs/_ftp_parse.py @@ -86,7 +86,15 @@ def parse_line(line): def _parse_time(t, formats): for frmt in formats: try: - _t = time.strptime(t, frmt) + if "%d" in frmt and "%Y" not in frmt: + # Cope with https://github.com/python/cpython/issues/70647 + # (deprecated in 3.13, removed in 3.15) by adding a year to + # achieve prior semantics. + _t = time.strptime( + time.strftime("%Y!", time.localtime()) + t, "%Y!" + frmt + ) + else: + _t = time.strptime(t, frmt) break except ValueError: continue