diff options
author | Victor Stinner <vstinner@python.org> | 2022-05-25 12:21:36 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-25 12:21:36 (GMT) |
commit | 71d8775feeb647ae5003cfd466de7b58cd1bf269 (patch) | |
tree | f20e104788f22dbc11c4366dce18fc74266294a8 /Objects | |
parent | 9485a0dbddcee014821b41c960133632bb68b33c (diff) | |
download | cpython-71d8775feeb647ae5003cfd466de7b58cd1bf269.zip cpython-71d8775feeb647ae5003cfd466de7b58cd1bf269.tar.gz cpython-71d8775feeb647ae5003cfd466de7b58cd1bf269.tar.bz2 |
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.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/object.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/Objects/object.c b/Objects/object.c index 95045ed..49b1cba 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -274,11 +274,8 @@ PyObject_Print(PyObject *op, FILE *fp, int flags) } else { if (Py_REFCNT(op) <= 0) { - /* XXX(twouters) cast refcount to long until %zd is - universally available */ Py_BEGIN_ALLOW_THREADS - fprintf(fp, "<refcnt %ld at %p>", - (long)Py_REFCNT(op), (void *)op); + fprintf(fp, "<refcnt %zd at %p>", Py_REFCNT(op), (void *)op); Py_END_ALLOW_THREADS } else { @@ -371,9 +368,7 @@ _PyObject_Dump(PyObject* op) /* first, write fields which are the least likely to crash */ fprintf(stderr, "object address : %p\n", (void *)op); - /* XXX(twouters) cast refcount to long until %zd is - universally available */ - fprintf(stderr, "object refcount : %ld\n", (long)Py_REFCNT(op)); + fprintf(stderr, "object refcount : %zd\n", Py_REFCNT(op)); fflush(stderr); PyTypeObject *type = Py_TYPE(op); |