mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
[3.13] gh-123017: Add Android to the list of platforms where strftime
doesn't support negative years (GH-124467) (#124674)
gh-123017: Add Android to the list of platforms where `strftime` doesn't support negative years (GH-124467)
Add Android to the list of platforms where `strftime` doesn't support negative years
(cherry picked from commit 0a3577bdfc
)
Co-authored-by: Malcolm Smith <smith@chaquo.com>
This commit is contained in:
parent
0c6ddadbc4
commit
8169d2971f
3 changed files with 9 additions and 3 deletions
|
@ -654,8 +654,7 @@ class _TestStrftimeYear:
|
||||||
self.test_year('%04d', func=year4d)
|
self.test_year('%04d', func=year4d)
|
||||||
|
|
||||||
def skip_if_not_supported(y):
|
def skip_if_not_supported(y):
|
||||||
msg = "strftime() is limited to [1; 9999] with Visual Studio"
|
msg = f"strftime() does not support year {y} on this platform"
|
||||||
# Check that it doesn't crash for year > 9999
|
|
||||||
try:
|
try:
|
||||||
time.strftime('%Y', (y,) + (0,) * 8)
|
time.strftime('%Y', (y,) + (0,) * 8)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Due to unreliable results on some devices, :func:`time.strftime` no longer
|
||||||
|
accepts negative years on Android.
|
|
@ -813,7 +813,12 @@ time_strftime(PyObject *module, PyObject *args)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_MSC_VER) || (defined(__sun) && defined(__SVR4)) || defined(_AIX) || defined(__VXWORKS__)
|
// Some platforms only support a limited range of years.
|
||||||
|
//
|
||||||
|
// Android works with negative years on the emulator, but fails on some
|
||||||
|
// physical devices (#123017).
|
||||||
|
#if defined(_MSC_VER) || (defined(__sun) && defined(__SVR4)) || defined(_AIX) \
|
||||||
|
|| defined(__VXWORKS__) || defined(__ANDROID__)
|
||||||
if (buf.tm_year + 1900 < 1 || 9999 < buf.tm_year + 1900) {
|
if (buf.tm_year + 1900 < 1 || 9999 < buf.tm_year + 1900) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"strftime() requires year in [1; 9999]");
|
"strftime() requires year in [1; 9999]");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue