https://github.com/python/cpython/commit/93933782d999ef58682a8713e5cd3cf92166048e
commit: 93933782d999ef58682a8713e5cd3cf92166048e
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2024-10-18T14:13:31Z
summary:

[3.12] Add tests for time.strftime() with invalid format string (GH-125696) 
(GH-125701)

(cherry picked from commit 2e950e341930ea79549137d4d3771d5edb940e65)

Co-authored-by: Serhiy Storchaka <[email protected]>

files:
M Lib/test/test_time.py

diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py
index b020787dacac1c..9463adda88db0d 100644
--- a/Lib/test/test_time.py
+++ b/Lib/test/test_time.py
@@ -14,7 +14,7 @@
 except ImportError:
     _testcapi = None
 
-from test.support import skip_if_buggy_ucrt_strfptime
+from test.support import skip_if_buggy_ucrt_strfptime, SuppressCrashReport
 
 # Max year is only limited by the size of C int.
 SIZEOF_INT = sysconfig.get_config_var('SIZEOF_INT') or 4
@@ -178,6 +178,17 @@ def test_strftime(self):
 
         self.assertRaises(TypeError, time.strftime, b'%S', tt)
 
+    def test_strftime_invalid_format(self):
+        tt = time.gmtime(self.t)
+        with SuppressCrashReport():
+            for i in range(1, 128):
+                format = ' %' + chr(i)
+                with self.subTest(format=format):
+                    try:
+                        time.strftime(format, tt)
+                    except ValueError as exc:
+                        self.assertEqual(str(exc), 'Invalid format string')
+
     def test_strftime_special(self):
         tt = time.gmtime(self.t)
         s1 = time.strftime('%c', tt)

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to