mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
gh-93202: Always use %zd printf formatter (#93201)
Python now always use the ``%zu`` and ``%zd`` printf formats to format a size_t or Py_ssize_t number. Building Python 3.12 requires a C11 compiler, so these printf formats are now always supported. * PyObject_Print() and _PyObject_Dump() now use the printf %zd format to display an object reference count. * Update PY_FORMAT_SIZE_T comment. * Remove outdated notes about the %zd format in PyBytes_FromFormat() and PyUnicode_FromFormat() documentations. * configure no longer checks for the %zd format and no longer defines PY_FORMAT_SIZE_T macro in pyconfig.h. * pymacconfig.h no longer undefines PY_FORMAT_SIZE_T: macOS 10.4 is no longer supported. Python 3.12 now requires macOS 10.6 (Snow Leopard) or newer.
This commit is contained in:
parent
9485a0dbdd
commit
71d8775fee
10 changed files with 11 additions and 168 deletions
66
configure
generated
vendored
66
configure
generated
vendored
|
|
@ -21150,72 +21150,6 @@ then
|
|||
LIBS="$LIBS -framework CoreFoundation"
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for %zd printf() format support" >&5
|
||||
$as_echo_n "checking for %zd printf() format support... " >&6; }
|
||||
if ${ac_cv_have_size_t_format+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
if test "$cross_compiling" = yes; then :
|
||||
ac_cv_have_size_t_format="cross -- assuming yes"
|
||||
|
||||
else
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SSIZE_T
|
||||
typedef ssize_t Py_ssize_t;
|
||||
#elif SIZEOF_VOID_P == SIZEOF_LONG
|
||||
typedef long Py_ssize_t;
|
||||
#else
|
||||
typedef int Py_ssize_t;
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
char buffer[256];
|
||||
|
||||
if(sprintf(buffer, "%zd", (size_t)123) < 0)
|
||||
return 1;
|
||||
|
||||
if (strcmp(buffer, "123"))
|
||||
return 1;
|
||||
|
||||
if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
|
||||
return 1;
|
||||
|
||||
if (strcmp(buffer, "-123"))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
_ACEOF
|
||||
if ac_fn_c_try_run "$LINENO"; then :
|
||||
ac_cv_have_size_t_format=yes
|
||||
else
|
||||
ac_cv_have_size_t_format=no
|
||||
fi
|
||||
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
|
||||
conftest.$ac_objext conftest.beam conftest.$ac_ext
|
||||
fi
|
||||
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_size_t_format" >&5
|
||||
$as_echo "$ac_cv_have_size_t_format" >&6; }
|
||||
if test "$ac_cv_have_size_t_format" != no ; then
|
||||
|
||||
$as_echo "#define PY_FORMAT_SIZE_T \"z\"" >>confdefs.h
|
||||
|
||||
fi
|
||||
|
||||
ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue