From cb04a09d2dfd197436a11de504b92773569e19fb Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Fri, 27 May 2022 17:00:45 +0530 Subject: GH-93207: Remove HAVE_STDARG_PROTOTYPES configure check for stdarg.h (#93215) --- Doc/whatsnew/3.12.rst | 5 +++ .../2022-05-25-13-56-00.gh-issue-93207.B9Rubf.rst | 3 ++ Modules/_asynciomodule.c | 4 -- Modules/_hashopenssl.c | 4 -- Objects/bytesobject.c | 4 -- Objects/exceptions.c | 4 -- Objects/unicodeobject.c | 4 -- PC/pyconfig.h | 3 -- Parser/tokenizer.c | 12 ------ Python/_warnings.c | 16 -------- Python/compile.c | 8 ---- Python/errors.c | 16 -------- Python/getargs.c | 8 ---- Python/hamt.c | 4 -- Python/pylifecycle.c | 4 -- Python/sysmodule.c | 8 ---- configure | 46 ---------------------- configure.ac | 23 +---------- pyconfig.h.in | 4 -- 19 files changed, 9 insertions(+), 171 deletions(-) create mode 100644 Misc/NEWS.d/next/Build/2022-05-25-13-56-00.gh-issue-93207.B9Rubf.rst diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index fd48784..4493476 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 0000000..cd462bb --- /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 5fa7223..c2b0e24 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 203366e..38776ed 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 1dfa1d5..8066088 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 cf8258b..e212e02 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 3acbf54..f712fbf 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 9dfe71b..2ddd584 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 header file. */ #define HAVE_SIGNAL_H 1 -/* Define if you have the prototypes. */ -#define HAVE_STDARG_PROTOTYPES - /* Define if you have the header file. */ #define HAVE_STDDEF_H 1 diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index b34dade..d5b549c 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 942308b..085ca45 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 d8f859e..541fa4c 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 3eb8a5e..b6b5d9b 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 ed3ffda..fb4a512 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 908c253..3aa31c6 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 8644b5b..42a0581 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 4f8b4cc..b9cae15 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 c72fc4a..04f0c4e 100755 --- a/configure +++ b/configure @@ -18418,52 +18418,6 @@ $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 -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 - # check for socketpair diff --git a/configure.ac b/configure.ac index a8d499d..9b5926d 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 -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* ]) -]) - # check for socketpair PY_CHECK_FUNC([socketpair], [ diff --git a/pyconfig.h.in b/pyconfig.h.in index b244ed2..a3bbbb8 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* */ -#undef HAVE_STDARG_PROTOTYPES - /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H -- cgit v0.12