Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0a3577b

Browse filesBrowse files
authored
gh-123017: Add Android to the list of platforms where strftime doesn't support negative years (#124467)
Add Android to the list of platforms where `strftime` doesn't support negative years
1 parent 365dffb commit 0a3577b
Copy full SHA for 0a3577b

File tree

3 files changed

+9
-3
lines changed
Filter options

3 files changed

+9
-3
lines changed

‎Lib/test/test_time.py

Copy file name to clipboardExpand all lines: Lib/test/test_time.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,8 +654,7 @@ def year4d(y):
654654
self.test_year('%04d', func=year4d)
655655

656656
def skip_if_not_supported(y):
657-
msg = "strftime() is limited to [1; 9999] with Visual Studio"
658-
# Check that it doesn't crash for year > 9999
657+
msg = f"strftime() does not support year {y} on this platform"
659658
try:
660659
time.strftime('%Y', (y,) + (0,) * 8)
661660
except ValueError:
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Due to unreliable results on some devices, :func:`time.strftime` no longer
2+
accepts negative years on Android.

‎Modules/timemodule.c

Copy file name to clipboardExpand all lines: Modules/timemodule.c
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,12 @@ time_strftime(PyObject *module, PyObject *args)
813813
return NULL;
814814
}
815815

816-
#if defined(_MSC_VER) || (defined(__sun) && defined(__SVR4)) || defined(_AIX) || defined(__VXWORKS__)
816+
// Some platforms only support a limited range of years.
817+
//
818+
// Android works with negative years on the emulator, but fails on some
819+
// physical devices (#123017).
820+
#if defined(_MSC_VER) || (defined(__sun) && defined(__SVR4)) || defined(_AIX) \
821+
|| defined(__VXWORKS__) || defined(__ANDROID__)
817822
if (buf.tm_year + 1900 < 1 || 9999 < buf.tm_year + 1900) {
818823
PyErr_SetString(PyExc_ValueError,
819824
"strftime() requires year in [1; 9999]");

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.