From 68fea4b4b9db4964d65d7eabcc45ef9eb14822da Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Thu, 19 Dec 2024 17:10:12 -0600 Subject: [PATCH 1/8] gh-128104: Remove `Py_STRFTIME_C99_SUPPORT`; require C99-compliant strftime --- Modules/_datetimemodule.c | 6 ------ configure | 12 +++++------- configure.ac | 9 ++++----- pyconfig.h.in | 3 --- 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index b1102984cb5e9e..368d10411366c4 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -1912,9 +1912,7 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple, } #ifdef Py_NORMALIZE_CENTURY else if (ch == 'Y' || ch == 'G' -#ifdef Py_STRFTIME_C99_SUPPORT || ch == 'F' || ch == 'C' -#endif ) { /* 0-pad year with century as necessary */ PyObject *item = PySequence_GetItem(timetuple, 0); @@ -1952,15 +1950,11 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple, * +6 to accommodate dashes, 2-digit month and day for %F. */ char buf[SIZEOF_LONG * 5 / 2 + 2 + 6]; Py_ssize_t n = PyOS_snprintf(buf, sizeof(buf), -#ifdef Py_STRFTIME_C99_SUPPORT ch == 'F' ? "%04ld-%%m-%%d" : -#endif "%04ld", year_long); -#ifdef Py_STRFTIME_C99_SUPPORT if (ch == 'C') { n -= 2; } -#endif if (_PyUnicodeWriter_WriteSubstring(&writer, format, start, end) < 0) { goto Error; } diff --git a/configure b/configure index 6df1116fc600f2..44bb5823e63ca4 100755 --- a/configure +++ b/configure @@ -26389,8 +26389,8 @@ printf "%s\n" "#define Py_NORMALIZE_CENTURY 1" >>confdefs.h fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C99-specific strftime specifiers are supported" >&5 -printf %s "checking whether C99-specific strftime specifiers are supported... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C99-compatible strftime specifiers are supported" >&5 +printf %s "checking whether C99-compatible strftime specifiers are supported... " >&6; } if test ${ac_cv_strftime_c99_support+y} then : printf %s "(cached) " >&6 @@ -26398,7 +26398,7 @@ else $as_nop if test "$cross_compiling" = yes then : - ac_cv_strftime_c99_support=no + ac_cv_strftime_c99_support=yes else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -26434,11 +26434,9 @@ fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_strftime_c99_support" >&5 printf "%s\n" "$ac_cv_strftime_c99_support" >&6; } -if test "$ac_cv_strftime_c99_support" = yes +if test "$ac_cv_strftime_c99_support" = no then - -printf "%s\n" "#define Py_STRFTIME_C99_SUPPORT 1" >>confdefs.h - + as_fn_error $? "Python requires C99-compatible strftime specifiers" "$LINENO" 5 fi have_curses=no diff --git a/configure.ac b/configure.ac index 8295b59b8e45fb..6292406813436e 100644 --- a/configure.ac +++ b/configure.ac @@ -6665,7 +6665,7 @@ then [Define if year with century should be normalized for strftime.]) fi -AC_CACHE_CHECK([whether C99-specific strftime specifiers are supported], [ac_cv_strftime_c99_support], [ +AC_CACHE_CHECK([whether C99-compatible strftime specifiers are supported], [ac_cv_strftime_c99_support], [ AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include @@ -6686,11 +6686,10 @@ int main(void) ]])], [ac_cv_strftime_c99_support=yes], [ac_cv_strftime_c99_support=no], -[ac_cv_strftime_c99_support=no])]) -if test "$ac_cv_strftime_c99_support" = yes +[ac_cv_strftime_c99_support=yes])]) +if test "$ac_cv_strftime_c99_support" = no then - AC_DEFINE([Py_STRFTIME_C99_SUPPORT], [1], - [Define if C99-specific strftime specifiers are supported.]) + AC_MSG_ERROR([Python requires C99-compatible strftime specifiers]) fi dnl check for ncursesw/ncurses and panelw/panel diff --git a/pyconfig.h.in b/pyconfig.h.in index 166c195a8c66fc..95d0115a6da18b 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -1712,9 +1712,6 @@ /* Define if you want to enable internal statistics gathering. */ #undef Py_STATS -/* Define if C99-specific strftime specifiers are supported. */ -#undef Py_STRFTIME_C99_SUPPORT - /* The version of SunOS/Solaris as reported by `uname -r' without the dot. */ #undef Py_SUNOS_VERSION From 0a9e225960d94a67913d30edc22cf1b92ab47049 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Fri, 20 Dec 2024 09:03:46 -0600 Subject: [PATCH 2/8] Add news entry --- .../next/Build/2024-12-20-09-03-22.gh-issue-128104.m_SoVx.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Misc/NEWS.d/next/Build/2024-12-20-09-03-22.gh-issue-128104.m_SoVx.rst diff --git a/Misc/NEWS.d/next/Build/2024-12-20-09-03-22.gh-issue-128104.m_SoVx.rst b/Misc/NEWS.d/next/Build/2024-12-20-09-03-22.gh-issue-128104.m_SoVx.rst new file mode 100644 index 00000000000000..c3a47fbecd1dad --- /dev/null +++ b/Misc/NEWS.d/next/Build/2024-12-20-09-03-22.gh-issue-128104.m_SoVx.rst @@ -0,0 +1,3 @@ +Remove ``Py_STRFTIME_C99_SUPPORT`` conditions in favor of requiring C99 +:manpage:`strftime(3)` specifier support at build time. When cross-compiling, +there is no build time check and support is assumed. From 63c1aab259f800fa4e22db8bd02cf0c42aaa1774 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Mon, 30 Dec 2024 12:30:54 -0600 Subject: [PATCH 3/8] Simplify; remove `ac_cv_strftime_c99_support` --- configure | 13 ++++++------- configure.ac | 9 ++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/configure b/configure index 9fd99db7c3859d..cae9fde7cfc75d 100755 --- a/configure +++ b/configure @@ -26404,7 +26404,10 @@ else $as_nop if test "$cross_compiling" = yes then : - ac_cv_strftime_c99_support=yes + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run test program while cross compiling +See \`config.log' for more details" "$LINENO" 5; } else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -26429,9 +26432,9 @@ int main(void) _ACEOF if ac_fn_c_try_run "$LINENO" then : - ac_cv_strftime_c99_support=yes + else $as_nop - ac_cv_strftime_c99_support=no + as_fn_error $? "Python requires C99-compatible strftime specifiers" "$LINENO" 5 fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext @@ -26440,10 +26443,6 @@ fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_strftime_c99_support" >&5 printf "%s\n" "$ac_cv_strftime_c99_support" >&6; } -if test "$ac_cv_strftime_c99_support" = no -then - as_fn_error $? "Python requires C99-compatible strftime specifiers" "$LINENO" 5 -fi have_curses=no have_panel=no diff --git a/configure.ac b/configure.ac index a72db99528386d..ccb0549dc33caf 100644 --- a/configure.ac +++ b/configure.ac @@ -6684,13 +6684,8 @@ int main(void) return 1; } ]])], -[ac_cv_strftime_c99_support=yes], -[ac_cv_strftime_c99_support=no], -[ac_cv_strftime_c99_support=yes])]) -if test "$ac_cv_strftime_c99_support" = no -then - AC_MSG_ERROR([Python requires C99-compatible strftime specifiers]) -fi +[], +[AC_MSG_ERROR([Python requires C99-compatible strftime specifiers])])]) dnl check for ncursesw/ncurses and panelw/panel dnl NOTE: old curses is not detected. From f2ae07a68826d44c880930c527a1a3c0efa48480 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Mon, 30 Dec 2024 13:08:19 -0600 Subject: [PATCH 4/8] Remove cache check --- configure | 10 ---------- configure.ac | 3 +-- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/configure b/configure index cae9fde7cfc75d..31af8b060c09b6 100755 --- a/configure +++ b/configure @@ -26395,13 +26395,6 @@ printf "%s\n" "#define Py_NORMALIZE_CENTURY 1" >>confdefs.h fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C99-compatible strftime specifiers are supported" >&5 -printf %s "checking whether C99-compatible strftime specifiers are supported... " >&6; } -if test ${ac_cv_strftime_c99_support+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes then : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 @@ -26440,9 +26433,6 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_strftime_c99_support" >&5 -printf "%s\n" "$ac_cv_strftime_c99_support" >&6; } have_curses=no have_panel=no diff --git a/configure.ac b/configure.ac index ccb0549dc33caf..cad36ba1011510 100644 --- a/configure.ac +++ b/configure.ac @@ -6665,7 +6665,6 @@ then [Define if year with century should be normalized for strftime.]) fi -AC_CACHE_CHECK([whether C99-compatible strftime specifiers are supported], [ac_cv_strftime_c99_support], [ AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include @@ -6685,7 +6684,7 @@ int main(void) } ]])], [], -[AC_MSG_ERROR([Python requires C99-compatible strftime specifiers])])]) +[AC_MSG_ERROR([Python requires C99-compatible strftime specifiers])]) dnl check for ncursesw/ncurses and panelw/panel dnl NOTE: old curses is not detected. From 7928672470c7d606d5554d22f3b3a60603966d95 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Mon, 30 Dec 2024 13:56:24 -0600 Subject: [PATCH 5/8] Include the empty if-cross-compiling block --- configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index cad36ba1011510..9b18eba4bc6b8d 100644 --- a/configure.ac +++ b/configure.ac @@ -6684,7 +6684,8 @@ int main(void) } ]])], [], -[AC_MSG_ERROR([Python requires C99-compatible strftime specifiers])]) +[AC_MSG_ERROR([Python requires C99-compatible strftime specifiers])], +[]) dnl check for ncursesw/ncurses and panelw/panel dnl NOTE: old curses is not detected. From 5f8de1bff4ba16a2c07389e2b50e08d70a3dac80 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Thu, 2 Jan 2025 15:09:04 -0600 Subject: [PATCH 6/8] Revert "Remove cache check" This reverts commit f2ae07a68826d44c880930c527a1a3c0efa48480. --- configure | 12 +++++++++++- configure.ac | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 31af8b060c09b6..012f5eb5c2494a 100755 --- a/configure +++ b/configure @@ -26395,6 +26395,13 @@ printf "%s\n" "#define Py_NORMALIZE_CENTURY 1" >>confdefs.h fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C99-compatible strftime specifiers are supported" >&5 +printf %s "checking whether C99-compatible strftime specifiers are supported... " >&6; } +if test ${ac_cv_strftime_c99_support+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test "$cross_compiling" = yes then : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 @@ -26432,7 +26439,10 @@ fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi - +) +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_strftime_c99_support" >&5 +printf "%s\n" "$ac_cv_strftime_c99_support" >&6; } have_curses=no have_panel=no diff --git a/configure.ac b/configure.ac index 9b18eba4bc6b8d..4c91292907c6ad 100644 --- a/configure.ac +++ b/configure.ac @@ -6665,6 +6665,7 @@ then [Define if year with century should be normalized for strftime.]) fi +AC_CACHE_CHECK([whether C99-compatible strftime specifiers are supported], [ac_cv_strftime_c99_support], [ AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include @@ -6685,7 +6686,7 @@ int main(void) ]])], [], [AC_MSG_ERROR([Python requires C99-compatible strftime specifiers])], -[]) +[]))]) dnl check for ncursesw/ncurses and panelw/panel dnl NOTE: old curses is not detected. From 629af8d1dfa8a4517a136a5b36678118495790fe Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Thu, 2 Jan 2025 15:13:22 -0600 Subject: [PATCH 7/8] Set `ac_cv_strftime_c99_support=yes` for cache --- configure | 4 ++-- configure.ac | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 012f5eb5c2494a..eec490902f9764 100755 --- a/configure +++ b/configure @@ -26432,14 +26432,14 @@ int main(void) _ACEOF if ac_fn_c_try_run "$LINENO" then : - + ac_cv_strftime_c99_support=yes else $as_nop as_fn_error $? "Python requires C99-compatible strftime specifiers" "$LINENO" 5 fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi -) + fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_strftime_c99_support" >&5 printf "%s\n" "$ac_cv_strftime_c99_support" >&6; } diff --git a/configure.ac b/configure.ac index 4c91292907c6ad..957ce237bb9d9e 100644 --- a/configure.ac +++ b/configure.ac @@ -6684,9 +6684,9 @@ int main(void) return 1; } ]])], -[], +[ac_cv_strftime_c99_support=yes], [AC_MSG_ERROR([Python requires C99-compatible strftime specifiers])], -[]))]) +[])]) dnl check for ncursesw/ncurses and panelw/panel dnl NOTE: old curses is not detected. From 67ce5393fe1b240bb1d1c1e06daa651db9af4b8a Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Thu, 2 Jan 2025 15:56:17 -0600 Subject: [PATCH 8/8] Set `ac_cv_strftime_c99_support` to empty string on cross-compile --- configure | 5 +---- configure.ac | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/configure b/configure index eec490902f9764..0d42b1bd509fd9 100755 --- a/configure +++ b/configure @@ -26404,10 +26404,7 @@ else $as_nop if test "$cross_compiling" = yes then : - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run test program while cross compiling -See \`config.log' for more details" "$LINENO" 5; } + ac_cv_strftime_c99_support= else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ diff --git a/configure.ac b/configure.ac index 957ce237bb9d9e..fc0c6156b8b69e 100644 --- a/configure.ac +++ b/configure.ac @@ -6686,7 +6686,7 @@ int main(void) ]])], [ac_cv_strftime_c99_support=yes], [AC_MSG_ERROR([Python requires C99-compatible strftime specifiers])], -[])]) +[ac_cv_strftime_c99_support=])]) dnl check for ncursesw/ncurses and panelw/panel dnl NOTE: old curses is not detected.