Skip to content

Commit bb2dfad

Browse files
authored
gh-128104: Remove Py_STRFTIME_C99_SUPPORT; require C99-compliant strftime (#128106)
1 parent bb73426 commit bb2dfad

File tree

5 files changed

+10
-27
lines changed

5 files changed

+10
-27
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Remove ``Py_STRFTIME_C99_SUPPORT`` conditions in favor of requiring C99
2+
:manpage:`strftime(3)` specifier support at build time. When cross-compiling,
3+
there is no build time check and support is assumed.

Modules/_datetimemodule.c

-6
Original file line numberDiff line numberDiff line change
@@ -1912,9 +1912,7 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
19121912
}
19131913
#ifdef Py_NORMALIZE_CENTURY
19141914
else if (ch == 'Y' || ch == 'G'
1915-
#ifdef Py_STRFTIME_C99_SUPPORT
19161915
|| ch == 'F' || ch == 'C'
1917-
#endif
19181916
) {
19191917
/* 0-pad year with century as necessary */
19201918
PyObject *item = PySequence_GetItem(timetuple, 0);
@@ -1952,15 +1950,11 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
19521950
* +6 to accommodate dashes, 2-digit month and day for %F. */
19531951
char buf[SIZEOF_LONG * 5 / 2 + 2 + 6];
19541952
Py_ssize_t n = PyOS_snprintf(buf, sizeof(buf),
1955-
#ifdef Py_STRFTIME_C99_SUPPORT
19561953
ch == 'F' ? "%04ld-%%m-%%d" :
1957-
#endif
19581954
"%04ld", year_long);
1959-
#ifdef Py_STRFTIME_C99_SUPPORT
19601955
if (ch == 'C') {
19611956
n -= 2;
19621957
}
1963-
#endif
19641958
if (_PyUnicodeWriter_WriteSubstring(&writer, format, start, end) < 0) {
19651959
goto Error;
19661960
}

configure

+4-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

+3-8
Original file line numberDiff line numberDiff line change
@@ -6672,7 +6672,7 @@ then
66726672
[Define if year with century should be normalized for strftime.])
66736673
fi
66746674

6675-
AC_CACHE_CHECK([whether C99-specific strftime specifiers are supported], [ac_cv_strftime_c99_support], [
6675+
AC_CACHE_CHECK([whether C99-compatible strftime specifiers are supported], [ac_cv_strftime_c99_support], [
66766676
AC_RUN_IFELSE([AC_LANG_SOURCE([[
66776677
#include <time.h>
66786678
#include <string.h>
@@ -6692,13 +6692,8 @@ int main(void)
66926692
}
66936693
]])],
66946694
[ac_cv_strftime_c99_support=yes],
6695-
[ac_cv_strftime_c99_support=no],
6696-
[ac_cv_strftime_c99_support=no])])
6697-
if test "$ac_cv_strftime_c99_support" = yes
6698-
then
6699-
AC_DEFINE([Py_STRFTIME_C99_SUPPORT], [1],
6700-
[Define if C99-specific strftime specifiers are supported.])
6701-
fi
6695+
[AC_MSG_ERROR([Python requires C99-compatible strftime specifiers])],
6696+
[ac_cv_strftime_c99_support=])])
67026697

67036698
dnl check for ncursesw/ncurses and panelw/panel
67046699
dnl NOTE: old curses is not detected.

pyconfig.h.in

-3
Original file line numberDiff line numberDiff line change
@@ -1715,9 +1715,6 @@
17151715
/* Define if you want to enable internal statistics gathering. */
17161716
#undef Py_STATS
17171717

1718-
/* Define if C99-specific strftime specifiers are supported. */
1719-
#undef Py_STRFTIME_C99_SUPPORT
1720-
17211718
/* The version of SunOS/Solaris as reported by `uname -r' without the dot. */
17221719
#undef Py_SUNOS_VERSION
17231720

0 commit comments

Comments
 (0)