[Python-checkins] GH-93207: Remove HAVE_STDARG_PROTOTYPES configure check for stdarg.h (#93215)

vstinner webhook-mailer at python.org
Fri May 27 07:30:53 EDT 2022


https://github.com/python/cpython/commit/cb04a09d2dfd197436a11de504b92773569e19fb
commit: cb04a09d2dfd197436a11de504b92773569e19fb
branch: main
author: Kumar Aditya <59607654+kumaraditya303 at users.noreply.github.com>
committer: vstinner <vstinner at python.org>
date: 2022-05-27T13:30:45+02:00
summary:

GH-93207: Remove HAVE_STDARG_PROTOTYPES configure check for stdarg.h (#93215)

files:
A Misc/NEWS.d/next/Build/2022-05-25-13-56-00.gh-issue-93207.B9Rubf.rst
M Doc/whatsnew/3.12.rst
M Modules/_asynciomodule.c
M Modules/_hashopenssl.c
M Objects/bytesobject.c
M Objects/exceptions.c
M Objects/unicodeobject.c
M PC/pyconfig.h
M Parser/tokenizer.c
M Python/_warnings.c
M Python/compile.c
M Python/errors.c
M Python/getargs.c
M Python/hamt.c
M Python/pylifecycle.c
M Python/sysmodule.c
M configure
M configure.ac
M pyconfig.h.in

diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst
index fd487848f09a3..4493476cb0318 100644
--- a/Doc/whatsnew/3.12.rst
+++ b/Doc/whatsnew/3.12.rst
@@ -144,6 +144,11 @@ Changes in the Python API
 Build Changes
 =============
 
+* ``va_start()`` with two parameters, like ``va_start(args, format),``
+  is now required to build Python.
+  ``va_start()`` is no longer called with a single parameter.
+  (Contributed by Kumar Aditya in :gh:`93207`.)
+
 
 C API Changes
 =============
diff --git a/Misc/NEWS.d/next/Build/2022-05-25-13-56-00.gh-issue-93207.B9Rubf.rst b/Misc/NEWS.d/next/Build/2022-05-25-13-56-00.gh-issue-93207.B9Rubf.rst
new file mode 100644
index 0000000000000..cd462bb232f04
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2022-05-25-13-56-00.gh-issue-93207.B9Rubf.rst
@@ -0,0 +1,3 @@
+``va_start()`` with two parameters, like ``va_start(args, format),``
+is now required to build Python. ``va_start()`` is no longer called with a single parameter.
+Patch by Kumar Aditya.
diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c
index 5fa722305757d..c2b0e242e277f 100644
--- a/Modules/_asynciomodule.c
+++ b/Modules/_asynciomodule.c
@@ -2643,11 +2643,7 @@ task_set_error_soon(TaskObj *task, PyObject *et, const char *format, ...)
     PyObject* msg;
 
     va_list vargs;
-#ifdef HAVE_STDARG_PROTOTYPES
     va_start(vargs, format);
-#else
-    va_start(vargs);
-#endif
     msg = PyUnicode_FromFormatV(format, vargs);
     va_end(vargs);
 
diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c
index 203366e380d4e..38776edf5f9fd 100644
--- a/Modules/_hashopenssl.c
+++ b/Modules/_hashopenssl.c
@@ -255,11 +255,7 @@ _setException(PyObject *exc, const char* altmsg, ...)
     const char *lib, *func, *reason;
     va_list vargs;
 
-#ifdef HAVE_STDARG_PROTOTYPES
     va_start(vargs, altmsg);
-#else
-    va_start(vargs);
-#endif
     if (!errcode) {
         if (altmsg == NULL) {
             PyErr_SetString(exc, "no reason supplied");
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 1dfa1d57cf65a..80660881920fb 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -377,11 +377,7 @@ PyBytes_FromFormat(const char *format, ...)
     PyObject* ret;
     va_list vargs;
 
-#ifdef HAVE_STDARG_PROTOTYPES
     va_start(vargs, format);
-#else
-    va_start(vargs);
-#endif
     ret = PyBytes_FromFormatV(format, vargs);
     va_end(vargs);
     return ret;
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index cf8258b0e244b..e212e02352efb 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -3816,11 +3816,7 @@ _PyErr_TrySetFromCause(const char *format, ...)
         Py_DECREF(tb);
     }
 
-#ifdef HAVE_STDARG_PROTOTYPES
     va_start(vargs, format);
-#else
-    va_start(vargs);
-#endif
     msg_prefix = PyUnicode_FromFormatV(format, vargs);
     va_end(vargs);
     if (msg_prefix == NULL) {
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 3acbf54f1c0b2..f712fbfa71d36 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -2708,11 +2708,7 @@ PyUnicode_FromFormat(const char *format, ...)
     PyObject* ret;
     va_list vargs;
 
-#ifdef HAVE_STDARG_PROTOTYPES
     va_start(vargs, format);
-#else
-    va_start(vargs);
-#endif
     ret = PyUnicode_FromFormatV(format, vargs);
     va_end(vargs);
     return ret;
diff --git a/PC/pyconfig.h b/PC/pyconfig.h
index 9dfe71bacabd1..2ddd5847f9c8a 100644
--- a/PC/pyconfig.h
+++ b/PC/pyconfig.h
@@ -569,9 +569,6 @@ Py_NO_ENABLE_SHARED to find out.  Also support MS_NO_COREDLL for b/w compat */
 /* Define to 1 if you have the <signal.h> header file. */
 #define HAVE_SIGNAL_H 1
 
-/* Define if you have the <stdarg.h> prototypes.  */
-#define HAVE_STDARG_PROTOTYPES
-
 /* Define if you have the <stddef.h> header file.  */
 #define HAVE_STDDEF_H 1
 
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index b34dade8f6d9b..d5b549c8706ce 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -1105,11 +1105,7 @@ static int
 syntaxerror(struct tok_state *tok, const char *format, ...)
 {
     va_list vargs;
-#ifdef HAVE_STDARG_PROTOTYPES
     va_start(vargs, format);
-#else
-    va_start(vargs);
-#endif
     int ret = _syntaxerror_range(tok, format, -1, -1, vargs);
     va_end(vargs);
     return ret;
@@ -1121,11 +1117,7 @@ syntaxerror_known_range(struct tok_state *tok,
                         const char *format, ...)
 {
     va_list vargs;
-#ifdef HAVE_STDARG_PROTOTYPES
     va_start(vargs, format);
-#else
-    va_start(vargs);
-#endif
     int ret = _syntaxerror_range(tok, format, col_offset, end_col_offset, vargs);
     va_end(vargs);
     return ret;
@@ -1146,11 +1138,7 @@ parser_warn(struct tok_state *tok, PyObject *category, const char *format, ...)
 {
     PyObject *errmsg;
     va_list vargs;
-#ifdef HAVE_STDARG_PROTOTYPES
     va_start(vargs, format);
-#else
-    va_start(vargs);
-#endif
     errmsg = PyUnicode_FromFormatV(format, vargs);
     va_end(vargs);
     if (!errmsg) {
diff --git a/Python/_warnings.c b/Python/_warnings.c
index 942308b357e33..085ca4506baae 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -1136,11 +1136,7 @@ PyErr_WarnFormat(PyObject *category, Py_ssize_t stack_level,
     int res;
     va_list vargs;
 
-#ifdef HAVE_STDARG_PROTOTYPES
     va_start(vargs, format);
-#else
-    va_start(vargs);
-#endif
     res = _PyErr_WarnFormatV(NULL, category, stack_level, format, vargs);
     va_end(vargs);
     return res;
@@ -1153,11 +1149,7 @@ _PyErr_WarnFormat(PyObject *source, PyObject *category, Py_ssize_t stack_level,
     int res;
     va_list vargs;
 
-#ifdef HAVE_STDARG_PROTOTYPES
     va_start(vargs, format);
-#else
-    va_start(vargs);
-#endif
     res = _PyErr_WarnFormatV(source, category, stack_level, format, vargs);
     va_end(vargs);
     return res;
@@ -1170,11 +1162,7 @@ PyErr_ResourceWarning(PyObject *source, Py_ssize_t stack_level,
     int res;
     va_list vargs;
 
-#ifdef HAVE_STDARG_PROTOTYPES
     va_start(vargs, format);
-#else
-    va_start(vargs);
-#endif
     res = _PyErr_WarnFormatV(source, PyExc_ResourceWarning,
                              stack_level, format, vargs);
     va_end(vargs);
@@ -1274,11 +1262,7 @@ PyErr_WarnExplicitFormat(PyObject *category,
             goto exit;
     }
 
-#ifdef HAVE_STDARG_PROTOTYPES
     va_start(vargs, format);
-#else
-    va_start(vargs);
-#endif
     message = PyUnicode_FromFormatV(format, vargs);
     if (message != NULL) {
         PyObject *res;
diff --git a/Python/compile.c b/Python/compile.c
index d8f859e7533a4..541fa4c9a12b9 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -6094,11 +6094,7 @@ static int
 compiler_error(struct compiler *c, const char *format, ...)
 {
     va_list vargs;
-#ifdef HAVE_STDARG_PROTOTYPES
     va_start(vargs, format);
-#else
-    va_start(vargs);
-#endif
     PyObject *msg = PyUnicode_FromFormatV(format, vargs);
     va_end(vargs);
     if (msg == NULL) {
@@ -6131,11 +6127,7 @@ static int
 compiler_warn(struct compiler *c, const char *format, ...)
 {
     va_list vargs;
-#ifdef HAVE_STDARG_PROTOTYPES
     va_start(vargs, format);
-#else
-    va_start(vargs);
-#endif
     PyObject *msg = PyUnicode_FromFormatV(format, vargs);
     va_end(vargs);
     if (msg == NULL) {
diff --git a/Python/errors.c b/Python/errors.c
index 3eb8a5ef04d28..b6b5d9b046ce8 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -688,11 +688,7 @@ _PyErr_FormatFromCauseTstate(PyThreadState *tstate, PyObject *exception,
                              const char *format, ...)
 {
     va_list vargs;
-#ifdef HAVE_STDARG_PROTOTYPES
     va_start(vargs, format);
-#else
-    va_start(vargs);
-#endif
     _PyErr_FormatVFromCause(tstate, exception, format, vargs);
     va_end(vargs);
     return NULL;
@@ -703,11 +699,7 @@ _PyErr_FormatFromCause(PyObject *exception, const char *format, ...)
 {
     PyThreadState *tstate = _PyThreadState_GET();
     va_list vargs;
-#ifdef HAVE_STDARG_PROTOTYPES
     va_start(vargs, format);
-#else
-    va_start(vargs);
-#endif
     _PyErr_FormatVFromCause(tstate, exception, format, vargs);
     va_end(vargs);
     return NULL;
@@ -1096,11 +1088,7 @@ _PyErr_Format(PyThreadState *tstate, PyObject *exception,
               const char *format, ...)
 {
     va_list vargs;
-#ifdef HAVE_STDARG_PROTOTYPES
     va_start(vargs, format);
-#else
-    va_start(vargs);
-#endif
     _PyErr_FormatV(tstate, exception, format, vargs);
     va_end(vargs);
     return NULL;
@@ -1112,11 +1100,7 @@ PyErr_Format(PyObject *exception, const char *format, ...)
 {
     PyThreadState *tstate = _PyThreadState_GET();
     va_list vargs;
-#ifdef HAVE_STDARG_PROTOTYPES
     va_start(vargs, format);
-#else
-    va_start(vargs);
-#endif
     _PyErr_FormatV(tstate, exception, format, vargs);
     va_end(vargs);
     return NULL;
diff --git a/Python/getargs.c b/Python/getargs.c
index ed3ffdafe37cd..fb4a5124beab8 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -2792,11 +2792,7 @@ PyArg_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t m
     stack = _PyTuple_ITEMS(args);
     nargs = PyTuple_GET_SIZE(args);
 
-#ifdef HAVE_STDARG_PROTOTYPES
     va_start(vargs, max);
-#else
-    va_start(vargs);
-#endif
     retval = unpack_stack(stack, nargs, name, min, max, vargs);
     va_end(vargs);
     return retval;
@@ -2809,11 +2805,7 @@ _PyArg_UnpackStack(PyObject *const *args, Py_ssize_t nargs, const char *name,
     int retval;
     va_list vargs;
 
-#ifdef HAVE_STDARG_PROTOTYPES
     va_start(vargs, max);
-#else
-    va_start(vargs);
-#endif
     retval = unpack_stack(args, nargs, name, min, max, vargs);
     va_end(vargs);
     return retval;
diff --git a/Python/hamt.c b/Python/hamt.c
index 908c253187031..3aa31c625824c 100644
--- a/Python/hamt.c
+++ b/Python/hamt.c
@@ -496,11 +496,7 @@ _hamt_dump_format(_PyUnicodeWriter *writer, const char *format, ...)
     int ret;
 
     va_list vargs;
-#ifdef HAVE_STDARG_PROTOTYPES
     va_start(vargs, format);
-#else
-    va_start(vargs);
-#endif
     msg = PyUnicode_FromFormatV(format, vargs);
     va_end(vargs);
 
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 8644b5b68b6c5..42a058181dd69 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -2838,11 +2838,7 @@ _Py_FatalErrorFormat(const char *func, const char *format, ...)
     }
 
     va_list vargs;
-#ifdef HAVE_STDARG_PROTOTYPES
     va_start(vargs, format);
-#else
-    va_start(vargs);
-#endif
     vfprintf(stream, format, vargs);
     va_end(vargs);
 
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 4f8b4cc17f2c1..b9cae15568d0f 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -292,11 +292,7 @@ _PySys_Audit(PyThreadState *tstate, const char *event,
              const char *argFormat, ...)
 {
     va_list vargs;
-#ifdef HAVE_STDARG_PROTOTYPES
     va_start(vargs, argFormat);
-#else
-    va_start(vargs);
-#endif
     int res = sys_audit_tstate(tstate, event, argFormat, vargs);
     va_end(vargs);
     return res;
@@ -307,11 +303,7 @@ PySys_Audit(const char *event, const char *argFormat, ...)
 {
     PyThreadState *tstate = _PyThreadState_GET();
     va_list vargs;
-#ifdef HAVE_STDARG_PROTOTYPES
     va_start(vargs, argFormat);
-#else
-    va_start(vargs);
-#endif
     int res = sys_audit_tstate(tstate, event, argFormat, vargs);
     va_end(vargs);
     return res;
diff --git a/configure b/configure
index c72fc4afdb9e6..04f0c4e0e8842 100755
--- a/configure
+++ b/configure
@@ -18416,52 +18416,6 @@ if test "x$ac_cv_function_prototypes" = xyes; then :
 $as_echo "#define HAVE_PROTOTYPES 1" >>confdefs.h
 
 
-fi
-
-works=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for variable length prototypes and stdarg.h" >&5
-$as_echo_n "checking for variable length prototypes and stdarg.h... " >&6; }
-if ${ac_cv_stdarg_prototypes+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <stdarg.h>
-int foo(int x, ...) {
-	va_list va;
-	va_start(va, x);
-	va_arg(va, int);
-	va_arg(va, char *);
-	va_arg(va, double);
-	return 0;
-}
-
-int
-main ()
-{
-return foo(10, "", 3.14);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_stdarg_prototypes=yes
-else
-  ac_cv_stdarg_prototypes=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_stdarg_prototypes" >&5
-$as_echo "$ac_cv_stdarg_prototypes" >&6; }
-if test "x$ac_cv_stdarg_prototypes" = xyes; then :
-
-
-$as_echo "#define HAVE_STDARG_PROTOTYPES 1" >>confdefs.h
-
-
 fi
 
 
diff --git a/configure.ac b/configure.ac
index a8d499df2f16d..9b5926d79d44e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1947,7 +1947,7 @@ AS_CASE([$ac_sys_system],
     dnl build with WASM debug info if either Py_DEBUG is set or the target is
     dnl node-debug or browser-debug.
     AS_VAR_IF([Py_DEBUG], [yes], [wasm_debug=yes], [wasm_debug=no])
-    
+
     dnl Start with 20 MB and allow to grow
     AS_VAR_APPEND([LDFLAGS_NODIST], [" -sALLOW_MEMORY_GROWTH -sTOTAL_MEMORY=20971520"])
 
@@ -5022,27 +5022,6 @@ AS_VAR_IF([ac_cv_function_prototypes], [yes], [
      [Define if your compiler supports function prototype])
 ])
 
-works=no
-AC_CACHE_CHECK([for variable length prototypes and stdarg.h], [ac_cv_stdarg_prototypes], [
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#include <stdarg.h>
-int foo(int x, ...) {
-	va_list va;
-	va_start(va, x);
-	va_arg(va, int);
-	va_arg(va, char *);
-	va_arg(va, double);
-	return 0;
-}
-]], [[return foo(10, "", 3.14);]])],
-  [ac_cv_stdarg_prototypes=yes], [ac_cv_stdarg_prototypes=no])
-])
-AS_VAR_IF([ac_cv_stdarg_prototypes], [yes], [
-  AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
-   [Define if your compiler supports variable length function prototypes
-   (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
-])
-
 
 # check for socketpair
 PY_CHECK_FUNC([socketpair], [
diff --git a/pyconfig.h.in b/pyconfig.h.in
index b244ed233d63a..a3bbbb894fd56 100644
--- a/pyconfig.h.in
+++ b/pyconfig.h.in
@@ -1115,10 +1115,6 @@
 /* Define if you have struct stat.st_mtimensec */
 #undef HAVE_STAT_TV_NSEC2
 
-/* Define if your compiler supports variable length function prototypes (e.g.
-   void fprintf(FILE *, char *, ...);) *and* <stdarg.h> */
-#undef HAVE_STDARG_PROTOTYPES
-
 /* Define to 1 if you have the <stdint.h> header file. */
 #undef HAVE_STDINT_H
 



More information about the Python-checkins mailing list