mirror of https://github.com/python/cpython
bpo-40943: Replace PY_FORMAT_SIZE_T with "z" (GH-20781)
The PEP 353, written in 2005, introduced PY_FORMAT_SIZE_T. Python no longer supports macOS 10.4 and Visual Studio 2010, but requires more recent macOS and Visual Studio versions. In 2020 with Python 3.10, it is now safe to use directly "%zu" to format size_t and "%zi" to format Py_ssize_t.
This commit is contained in:
parent
24b8bad6d3
commit
d36cf5f1d2
|
@ -131,7 +131,9 @@ typedef int Py_ssize_clean_t;
|
||||||
/* Smallest negative value of type Py_ssize_t. */
|
/* Smallest negative value of type Py_ssize_t. */
|
||||||
#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
|
#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
|
||||||
|
|
||||||
/* PY_FORMAT_SIZE_T is a platform-specific modifier for use in a printf
|
/* Macro kept for backward compatibility: use "z" in new code.
|
||||||
|
*
|
||||||
|
* PY_FORMAT_SIZE_T is a platform-specific modifier for use in a printf
|
||||||
* format to convert an argument with the width of a size_t or Py_ssize_t.
|
* format to convert an argument with the width of a size_t or Py_ssize_t.
|
||||||
* C99 introduced "z" for this purpose, but old MSVCs had not supported it.
|
* C99 introduced "z" for this purpose, but old MSVCs had not supported it.
|
||||||
* Since MSVC supports "z" since (at least) 2015, we can just use "z"
|
* Since MSVC supports "z" since (at least) 2015, we can just use "z"
|
||||||
|
|
|
@ -1715,7 +1715,7 @@ memo_get(PicklerObject *self, PyObject *key)
|
||||||
if (!self->bin) {
|
if (!self->bin) {
|
||||||
pdata[0] = GET;
|
pdata[0] = GET;
|
||||||
PyOS_snprintf(pdata + 1, sizeof(pdata) - 1,
|
PyOS_snprintf(pdata + 1, sizeof(pdata) - 1,
|
||||||
"%" PY_FORMAT_SIZE_T "d\n", *value);
|
"%zd\n", *value);
|
||||||
len = strlen(pdata);
|
len = strlen(pdata);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1772,7 +1772,7 @@ memo_put(PicklerObject *self, PyObject *obj)
|
||||||
else if (!self->bin) {
|
else if (!self->bin) {
|
||||||
pdata[0] = PUT;
|
pdata[0] = PUT;
|
||||||
PyOS_snprintf(pdata + 1, sizeof(pdata) - 1,
|
PyOS_snprintf(pdata + 1, sizeof(pdata) - 1,
|
||||||
"%" PY_FORMAT_SIZE_T "d\n", idx);
|
"%zd\n", idx);
|
||||||
len = strlen(pdata);
|
len = strlen(pdata);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -211,7 +211,7 @@ data_stack_grow(SRE_STATE* state, Py_ssize_t size)
|
||||||
if (cursize < minsize) {
|
if (cursize < minsize) {
|
||||||
void* stack;
|
void* stack;
|
||||||
cursize = minsize+minsize/4+1024;
|
cursize = minsize+minsize/4+1024;
|
||||||
TRACE(("allocate/grow stack %" PY_FORMAT_SIZE_T "d\n", cursize));
|
TRACE(("allocate/grow stack %zd\n", cursize));
|
||||||
stack = PyMem_REALLOC(state->data_stack, cursize);
|
stack = PyMem_REALLOC(state->data_stack, cursize);
|
||||||
if (!stack) {
|
if (!stack) {
|
||||||
data_stack_dealloc(state);
|
data_stack_dealloc(state);
|
||||||
|
|
|
@ -1043,7 +1043,7 @@ show_stats_each_generations(GCState *gcstate)
|
||||||
|
|
||||||
for (int i = 0; i < NUM_GENERATIONS && pos < sizeof(buf); i++) {
|
for (int i = 0; i < NUM_GENERATIONS && pos < sizeof(buf); i++) {
|
||||||
pos += PyOS_snprintf(buf+pos, sizeof(buf)-pos,
|
pos += PyOS_snprintf(buf+pos, sizeof(buf)-pos,
|
||||||
" %"PY_FORMAT_SIZE_T"d",
|
" %zd",
|
||||||
gc_list_size(GEN_HEAD(gcstate, i)));
|
gc_list_size(GEN_HEAD(gcstate, i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1290,8 +1290,7 @@ collect(PyThreadState *tstate, int generation,
|
||||||
if (gcstate->debug & DEBUG_STATS) {
|
if (gcstate->debug & DEBUG_STATS) {
|
||||||
double d = _PyTime_AsSecondsDouble(_PyTime_GetMonotonicClock() - t1);
|
double d = _PyTime_AsSecondsDouble(_PyTime_GetMonotonicClock() - t1);
|
||||||
PySys_WriteStderr(
|
PySys_WriteStderr(
|
||||||
"gc: done, %" PY_FORMAT_SIZE_T "d unreachable, "
|
"gc: done, %zd unreachable, %zd uncollectable, %.4fs elapsed\n",
|
||||||
"%" PY_FORMAT_SIZE_T "d uncollectable, %.4fs elapsed\n",
|
|
||||||
n+m, n, d);
|
n+m, n, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -323,12 +323,12 @@ SRE(count)(SRE_STATE* state, const SRE_CODE* pattern, Py_ssize_t maxcount)
|
||||||
if (!i)
|
if (!i)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
TRACE(("|%p|%p|COUNT %" PY_FORMAT_SIZE_T "d\n", pattern, ptr,
|
TRACE(("|%p|%p|COUNT %zd\n", pattern, ptr,
|
||||||
(SRE_CHAR*) state->ptr - ptr));
|
(SRE_CHAR*) state->ptr - ptr));
|
||||||
return (SRE_CHAR*) state->ptr - ptr;
|
return (SRE_CHAR*) state->ptr - ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE(("|%p|%p|COUNT %" PY_FORMAT_SIZE_T "d\n", pattern, ptr,
|
TRACE(("|%p|%p|COUNT %zd\n", pattern, ptr,
|
||||||
ptr - (SRE_CHAR*) state->ptr));
|
ptr - (SRE_CHAR*) state->ptr));
|
||||||
return ptr - (SRE_CHAR*) state->ptr;
|
return ptr - (SRE_CHAR*) state->ptr;
|
||||||
}
|
}
|
||||||
|
@ -414,8 +414,7 @@ SRE(info)(SRE_STATE* state, const SRE_CODE* pattern)
|
||||||
#define DATA_STACK_ALLOC(state, type, ptr) \
|
#define DATA_STACK_ALLOC(state, type, ptr) \
|
||||||
do { \
|
do { \
|
||||||
alloc_pos = state->data_stack_base; \
|
alloc_pos = state->data_stack_base; \
|
||||||
TRACE(("allocating %s in %" PY_FORMAT_SIZE_T "d " \
|
TRACE(("allocating %s in %zd (%zd)\n", \
|
||||||
"(%" PY_FORMAT_SIZE_T "d)\n", \
|
|
||||||
Py_STRINGIFY(type), alloc_pos, sizeof(type))); \
|
Py_STRINGIFY(type), alloc_pos, sizeof(type))); \
|
||||||
if (sizeof(type) > state->data_stack_size - alloc_pos) { \
|
if (sizeof(type) > state->data_stack_size - alloc_pos) { \
|
||||||
int j = data_stack_grow(state, sizeof(type)); \
|
int j = data_stack_grow(state, sizeof(type)); \
|
||||||
|
@ -429,14 +428,13 @@ do { \
|
||||||
|
|
||||||
#define DATA_STACK_LOOKUP_AT(state, type, ptr, pos) \
|
#define DATA_STACK_LOOKUP_AT(state, type, ptr, pos) \
|
||||||
do { \
|
do { \
|
||||||
TRACE(("looking up %s at %" PY_FORMAT_SIZE_T "d\n", Py_STRINGIFY(type), pos)); \
|
TRACE(("looking up %s at %zd\n", Py_STRINGIFY(type), pos)); \
|
||||||
ptr = (type*)(state->data_stack+pos); \
|
ptr = (type*)(state->data_stack+pos); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define DATA_STACK_PUSH(state, data, size) \
|
#define DATA_STACK_PUSH(state, data, size) \
|
||||||
do { \
|
do { \
|
||||||
TRACE(("copy data in %p to %" PY_FORMAT_SIZE_T "d " \
|
TRACE(("copy data in %p to %zd (%zd)\n", \
|
||||||
"(%" PY_FORMAT_SIZE_T "d)\n", \
|
|
||||||
data, state->data_stack_base, size)); \
|
data, state->data_stack_base, size)); \
|
||||||
if (size > state->data_stack_size - state->data_stack_base) { \
|
if (size > state->data_stack_size - state->data_stack_base) { \
|
||||||
int j = data_stack_grow(state, size); \
|
int j = data_stack_grow(state, size); \
|
||||||
|
@ -453,8 +451,7 @@ do { \
|
||||||
safely casted to `void*`, see bpo-39943 for details. */
|
safely casted to `void*`, see bpo-39943 for details. */
|
||||||
#define DATA_STACK_POP(state, data, size, discard) \
|
#define DATA_STACK_POP(state, data, size, discard) \
|
||||||
do { \
|
do { \
|
||||||
TRACE(("copy data to %p from %" PY_FORMAT_SIZE_T "d " \
|
TRACE(("copy data to %p from %zd (%zd)\n", \
|
||||||
"(%" PY_FORMAT_SIZE_T "d)\n", \
|
|
||||||
data, state->data_stack_base-size, size)); \
|
data, state->data_stack_base-size, size)); \
|
||||||
memcpy((void*) data, state->data_stack+state->data_stack_base-size, size); \
|
memcpy((void*) data, state->data_stack+state->data_stack_base-size, size); \
|
||||||
if (discard) \
|
if (discard) \
|
||||||
|
@ -463,8 +460,7 @@ do { \
|
||||||
|
|
||||||
#define DATA_STACK_POP_DISCARD(state, size) \
|
#define DATA_STACK_POP_DISCARD(state, size) \
|
||||||
do { \
|
do { \
|
||||||
TRACE(("discard data from %" PY_FORMAT_SIZE_T "d " \
|
TRACE(("discard data from %zd (%zd)\n", \
|
||||||
"(%" PY_FORMAT_SIZE_T "d)\n", \
|
|
||||||
state->data_stack_base-size, size)); \
|
state->data_stack_base-size, size)); \
|
||||||
state->data_stack_base -= size; \
|
state->data_stack_base -= size; \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
@ -577,8 +573,7 @@ entrance:
|
||||||
/* optimization info block */
|
/* optimization info block */
|
||||||
/* <INFO> <1=skip> <2=flags> <3=min> ... */
|
/* <INFO> <1=skip> <2=flags> <3=min> ... */
|
||||||
if (ctx->pattern[3] && (uintptr_t)(end - ctx->ptr) < ctx->pattern[3]) {
|
if (ctx->pattern[3] && (uintptr_t)(end - ctx->ptr) < ctx->pattern[3]) {
|
||||||
TRACE(("reject (got %" PY_FORMAT_SIZE_T "d chars, "
|
TRACE(("reject (got %zd chars, need %zd)\n",
|
||||||
"need %" PY_FORMAT_SIZE_T "d)\n",
|
|
||||||
end - ctx->ptr, (Py_ssize_t) ctx->pattern[3]));
|
end - ctx->ptr, (Py_ssize_t) ctx->pattern[3]));
|
||||||
RETURN_FAILURE;
|
RETURN_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -1028,7 +1023,7 @@ entrance:
|
||||||
|
|
||||||
ctx->count = ctx->u.rep->count+1;
|
ctx->count = ctx->u.rep->count+1;
|
||||||
|
|
||||||
TRACE(("|%p|%p|MAX_UNTIL %" PY_FORMAT_SIZE_T "d\n", ctx->pattern,
|
TRACE(("|%p|%p|MAX_UNTIL %zd\n", ctx->pattern,
|
||||||
ctx->ptr, ctx->count));
|
ctx->ptr, ctx->count));
|
||||||
|
|
||||||
if (ctx->count < (Py_ssize_t) ctx->u.rep->pattern[1]) {
|
if (ctx->count < (Py_ssize_t) ctx->u.rep->pattern[1]) {
|
||||||
|
@ -1091,7 +1086,7 @@ entrance:
|
||||||
|
|
||||||
ctx->count = ctx->u.rep->count+1;
|
ctx->count = ctx->u.rep->count+1;
|
||||||
|
|
||||||
TRACE(("|%p|%p|MIN_UNTIL %" PY_FORMAT_SIZE_T "d %p\n", ctx->pattern,
|
TRACE(("|%p|%p|MIN_UNTIL %zd %p\n", ctx->pattern,
|
||||||
ctx->ptr, ctx->count, ctx->u.rep->pattern));
|
ctx->ptr, ctx->count, ctx->u.rep->pattern));
|
||||||
|
|
||||||
if (ctx->count < (Py_ssize_t) ctx->u.rep->pattern[1]) {
|
if (ctx->count < (Py_ssize_t) ctx->u.rep->pattern[1]) {
|
||||||
|
@ -1358,7 +1353,7 @@ exit:
|
||||||
TRACE(("|%p|%p|JUMP_ASSERT_NOT\n", ctx->pattern, ctx->ptr));
|
TRACE(("|%p|%p|JUMP_ASSERT_NOT\n", ctx->pattern, ctx->ptr));
|
||||||
goto jump_assert_not;
|
goto jump_assert_not;
|
||||||
case JUMP_NONE:
|
case JUMP_NONE:
|
||||||
TRACE(("|%p|%p|RETURN %" PY_FORMAT_SIZE_T "d\n", ctx->pattern,
|
TRACE(("|%p|%p|RETURN %zd\n", ctx->pattern,
|
||||||
ctx->ptr, ret));
|
ctx->ptr, ret));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1420,7 +1415,7 @@ SRE(search)(SRE_STATE* state, SRE_CODE* pattern)
|
||||||
pattern += 1 + pattern[1];
|
pattern += 1 + pattern[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE(("prefix = %p %" PY_FORMAT_SIZE_T "d %" PY_FORMAT_SIZE_T "d\n",
|
TRACE(("prefix = %p %zd %zd\n",
|
||||||
prefix, prefix_len, prefix_skip));
|
prefix, prefix_len, prefix_skip));
|
||||||
TRACE(("charset = %p\n", charset));
|
TRACE(("charset = %p\n", charset));
|
||||||
|
|
||||||
|
|
|
@ -256,27 +256,29 @@ PyBytes_FromFormatV(const char *format, va_list vargs)
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
if (longflag)
|
if (longflag) {
|
||||||
sprintf(buffer, "%ld", va_arg(vargs, long));
|
sprintf(buffer, "%ld", va_arg(vargs, long));
|
||||||
else if (size_tflag)
|
}
|
||||||
sprintf(buffer, "%" PY_FORMAT_SIZE_T "d",
|
else if (size_tflag) {
|
||||||
va_arg(vargs, Py_ssize_t));
|
sprintf(buffer, "%zd", va_arg(vargs, Py_ssize_t));
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
sprintf(buffer, "%d", va_arg(vargs, int));
|
sprintf(buffer, "%d", va_arg(vargs, int));
|
||||||
|
}
|
||||||
assert(strlen(buffer) < sizeof(buffer));
|
assert(strlen(buffer) < sizeof(buffer));
|
||||||
WRITE_BYTES(buffer);
|
WRITE_BYTES(buffer);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'u':
|
case 'u':
|
||||||
if (longflag)
|
if (longflag) {
|
||||||
sprintf(buffer, "%lu",
|
sprintf(buffer, "%lu", va_arg(vargs, unsigned long));
|
||||||
va_arg(vargs, unsigned long));
|
}
|
||||||
else if (size_tflag)
|
else if (size_tflag) {
|
||||||
sprintf(buffer, "%" PY_FORMAT_SIZE_T "u",
|
sprintf(buffer, "%zu", va_arg(vargs, size_t));
|
||||||
va_arg(vargs, size_t));
|
}
|
||||||
else
|
else {
|
||||||
sprintf(buffer, "%u",
|
sprintf(buffer, "%u", va_arg(vargs, unsigned int));
|
||||||
va_arg(vargs, unsigned int));
|
}
|
||||||
assert(strlen(buffer) < sizeof(buffer));
|
assert(strlen(buffer) < sizeof(buffer));
|
||||||
WRITE_BYTES(buffer);
|
WRITE_BYTES(buffer);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -66,8 +66,7 @@ _Py_GetRefTotal(void)
|
||||||
void
|
void
|
||||||
_PyDebug_PrintTotalRefs(void) {
|
_PyDebug_PrintTotalRefs(void) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"[%" PY_FORMAT_SIZE_T "d refs, "
|
"[%zd refs, %zd blocks]\n",
|
||||||
"%" PY_FORMAT_SIZE_T "d blocks]\n",
|
|
||||||
_Py_GetRefTotal(), _Py_GetAllocatedBlocks());
|
_Py_GetRefTotal(), _Py_GetAllocatedBlocks());
|
||||||
}
|
}
|
||||||
#endif /* Py_REF_DEBUG */
|
#endif /* Py_REF_DEBUG */
|
||||||
|
@ -1876,9 +1875,10 @@ _Py_PrintReferences(FILE *fp)
|
||||||
PyObject *op;
|
PyObject *op;
|
||||||
fprintf(fp, "Remaining objects:\n");
|
fprintf(fp, "Remaining objects:\n");
|
||||||
for (op = refchain._ob_next; op != &refchain; op = op->_ob_next) {
|
for (op = refchain._ob_next; op != &refchain; op = op->_ob_next) {
|
||||||
fprintf(fp, "%p [%" PY_FORMAT_SIZE_T "d] ", (void *)op, Py_REFCNT(op));
|
fprintf(fp, "%p [%zd] ", (void *)op, Py_REFCNT(op));
|
||||||
if (PyObject_Print(op, fp, 0) != 0)
|
if (PyObject_Print(op, fp, 0) != 0) {
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
|
}
|
||||||
putc('\n', fp);
|
putc('\n', fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1892,7 +1892,7 @@ _Py_PrintReferenceAddresses(FILE *fp)
|
||||||
PyObject *op;
|
PyObject *op;
|
||||||
fprintf(fp, "Remaining object addresses:\n");
|
fprintf(fp, "Remaining object addresses:\n");
|
||||||
for (op = refchain._ob_next; op != &refchain; op = op->_ob_next)
|
for (op = refchain._ob_next; op != &refchain; op = op->_ob_next)
|
||||||
fprintf(fp, "%p [%" PY_FORMAT_SIZE_T "d] %s\n", (void *)op,
|
fprintf(fp, "%p [%zd] %s\n", (void *)op,
|
||||||
Py_REFCNT(op), Py_TYPE(op)->tp_name);
|
Py_REFCNT(op), Py_TYPE(op)->tp_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2420,8 +2420,7 @@ _PyObject_DebugDumpAddress(const void *p)
|
||||||
fprintf(stderr, " API '%c'\n", id);
|
fprintf(stderr, " API '%c'\n", id);
|
||||||
|
|
||||||
nbytes = read_size_t(q - 2*SST);
|
nbytes = read_size_t(q - 2*SST);
|
||||||
fprintf(stderr, " %" PY_FORMAT_SIZE_T "u bytes originally "
|
fprintf(stderr, " %zu bytes originally requested\n", nbytes);
|
||||||
"requested\n", nbytes);
|
|
||||||
|
|
||||||
/* In case this is nuts, check the leading pad bytes first. */
|
/* In case this is nuts, check the leading pad bytes first. */
|
||||||
fprintf(stderr, " The %d pad bytes at p-%d are ", SST-1, SST-1);
|
fprintf(stderr, " The %d pad bytes at p-%d are ", SST-1, SST-1);
|
||||||
|
@ -2477,8 +2476,9 @@ _PyObject_DebugDumpAddress(const void *p)
|
||||||
|
|
||||||
#ifdef PYMEM_DEBUG_SERIALNO
|
#ifdef PYMEM_DEBUG_SERIALNO
|
||||||
size_t serial = read_size_t(tail + SST);
|
size_t serial = read_size_t(tail + SST);
|
||||||
fprintf(stderr, " The block was made by call #%" PY_FORMAT_SIZE_T
|
fprintf(stderr,
|
||||||
"u to debug malloc/realloc.\n", serial);
|
" The block was made by call #%zu to debug malloc/realloc.\n",
|
||||||
|
serial);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (nbytes > 0) {
|
if (nbytes > 0) {
|
||||||
|
@ -2553,7 +2553,7 @@ _PyDebugAllocatorStats(FILE *out,
|
||||||
char buf1[128];
|
char buf1[128];
|
||||||
char buf2[128];
|
char buf2[128];
|
||||||
PyOS_snprintf(buf1, sizeof(buf1),
|
PyOS_snprintf(buf1, sizeof(buf1),
|
||||||
"%d %ss * %" PY_FORMAT_SIZE_T "d bytes each",
|
"%d %ss * %zd bytes each",
|
||||||
num_blocks, block_name, sizeof_block);
|
num_blocks, block_name, sizeof_block);
|
||||||
PyOS_snprintf(buf2, sizeof(buf2),
|
PyOS_snprintf(buf2, sizeof(buf2),
|
||||||
"%48s ", buf1);
|
"%48s ", buf1);
|
||||||
|
@ -2694,10 +2694,7 @@ _PyObject_DebugMallocStats(FILE *out)
|
||||||
assert(b == 0 && f == 0);
|
assert(b == 0 && f == 0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
fprintf(out, "%5u %6u "
|
fprintf(out, "%5u %6u %11zu %15zu %13zu\n",
|
||||||
"%11" PY_FORMAT_SIZE_T "u "
|
|
||||||
"%15" PY_FORMAT_SIZE_T "u "
|
|
||||||
"%13" PY_FORMAT_SIZE_T "u\n",
|
|
||||||
i, size, p, b, f);
|
i, size, p, b, f);
|
||||||
allocated_bytes += b * size;
|
allocated_bytes += b * size;
|
||||||
available_bytes += f * size;
|
available_bytes += f * size;
|
||||||
|
@ -2716,8 +2713,8 @@ _PyObject_DebugMallocStats(FILE *out)
|
||||||
(void)printone(out, "# arenas allocated current", narenas);
|
(void)printone(out, "# arenas allocated current", narenas);
|
||||||
|
|
||||||
PyOS_snprintf(buf, sizeof(buf),
|
PyOS_snprintf(buf, sizeof(buf),
|
||||||
"%" PY_FORMAT_SIZE_T "u arenas * %d bytes/arena",
|
"%zu arenas * %d bytes/arena",
|
||||||
narenas, ARENA_SIZE);
|
narenas, ARENA_SIZE);
|
||||||
(void)printone(out, buf, narenas * ARENA_SIZE);
|
(void)printone(out, buf, narenas * ARENA_SIZE);
|
||||||
|
|
||||||
fputc('\n', out);
|
fputc('\n', out);
|
||||||
|
|
|
@ -1356,19 +1356,18 @@ _PyUnicode_Dump(PyObject *op)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
data = unicode->data.any;
|
data = unicode->data.any;
|
||||||
printf("%s: len=%" PY_FORMAT_SIZE_T "u, ",
|
printf("%s: len=%zu, ", unicode_kind_name(op), ascii->length);
|
||||||
unicode_kind_name(op), ascii->length);
|
|
||||||
|
|
||||||
if (ascii->wstr == data)
|
if (ascii->wstr == data)
|
||||||
printf("shared ");
|
printf("shared ");
|
||||||
printf("wstr=%p", (void *)ascii->wstr);
|
printf("wstr=%p", (void *)ascii->wstr);
|
||||||
|
|
||||||
if (!(ascii->state.ascii == 1 && ascii->state.compact == 1)) {
|
if (!(ascii->state.ascii == 1 && ascii->state.compact == 1)) {
|
||||||
printf(" (%" PY_FORMAT_SIZE_T "u), ", compact->wstr_length);
|
printf(" (%zu), ", compact->wstr_length);
|
||||||
if (!ascii->state.compact && compact->utf8 == unicode->data.any)
|
if (!ascii->state.compact && compact->utf8 == unicode->data.any) {
|
||||||
printf("shared ");
|
printf("shared ");
|
||||||
printf("utf8=%p (%" PY_FORMAT_SIZE_T "u)",
|
}
|
||||||
(void *)compact->utf8, compact->utf8_length);
|
printf("utf8=%p (%zu)", (void *)compact->utf8, compact->utf8_length);
|
||||||
}
|
}
|
||||||
printf(", data=%p\n", data);
|
printf(", data=%p\n", data);
|
||||||
}
|
}
|
||||||
|
@ -2845,35 +2844,35 @@ unicode_fromformat_arg(_PyUnicodeWriter *writer,
|
||||||
Py_ssize_t arglen;
|
Py_ssize_t arglen;
|
||||||
|
|
||||||
if (*f == 'u') {
|
if (*f == 'u') {
|
||||||
if (longflag)
|
if (longflag) {
|
||||||
len = sprintf(buffer, "%lu",
|
len = sprintf(buffer, "%lu", va_arg(*vargs, unsigned long));
|
||||||
va_arg(*vargs, unsigned long));
|
}
|
||||||
else if (longlongflag)
|
else if (longlongflag) {
|
||||||
len = sprintf(buffer, "%llu",
|
len = sprintf(buffer, "%llu", va_arg(*vargs, unsigned long long));
|
||||||
va_arg(*vargs, unsigned long long));
|
}
|
||||||
else if (size_tflag)
|
else if (size_tflag) {
|
||||||
len = sprintf(buffer, "%" PY_FORMAT_SIZE_T "u",
|
len = sprintf(buffer, "%zu", va_arg(*vargs, size_t));
|
||||||
va_arg(*vargs, size_t));
|
}
|
||||||
else
|
else {
|
||||||
len = sprintf(buffer, "%u",
|
len = sprintf(buffer, "%u", va_arg(*vargs, unsigned int));
|
||||||
va_arg(*vargs, unsigned int));
|
}
|
||||||
}
|
}
|
||||||
else if (*f == 'x') {
|
else if (*f == 'x') {
|
||||||
len = sprintf(buffer, "%x", va_arg(*vargs, int));
|
len = sprintf(buffer, "%x", va_arg(*vargs, int));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (longflag)
|
if (longflag) {
|
||||||
len = sprintf(buffer, "%li",
|
len = sprintf(buffer, "%li", va_arg(*vargs, long));
|
||||||
va_arg(*vargs, long));
|
}
|
||||||
else if (longlongflag)
|
else if (longlongflag) {
|
||||||
len = sprintf(buffer, "%lli",
|
len = sprintf(buffer, "%lli", va_arg(*vargs, long long));
|
||||||
va_arg(*vargs, long long));
|
}
|
||||||
else if (size_tflag)
|
else if (size_tflag) {
|
||||||
len = sprintf(buffer, "%" PY_FORMAT_SIZE_T "i",
|
len = sprintf(buffer, "%zi", va_arg(*vargs, Py_ssize_t));
|
||||||
va_arg(*vargs, Py_ssize_t));
|
}
|
||||||
else
|
else {
|
||||||
len = sprintf(buffer, "%i",
|
len = sprintf(buffer, "%i", va_arg(*vargs, int));
|
||||||
va_arg(*vargs, int));
|
}
|
||||||
}
|
}
|
||||||
assert(len >= 0);
|
assert(len >= 0);
|
||||||
|
|
||||||
|
@ -15657,8 +15656,7 @@ unicode_release_interned(void)
|
||||||
|
|
||||||
Py_ssize_t n = PyList_GET_SIZE(keys);
|
Py_ssize_t n = PyList_GET_SIZE(keys);
|
||||||
#ifdef INTERNED_STATS
|
#ifdef INTERNED_STATS
|
||||||
fprintf(stderr, "releasing %" PY_FORMAT_SIZE_T "d interned strings\n",
|
fprintf(stderr, "releasing %zd interned strings\n", n);
|
||||||
n);
|
|
||||||
|
|
||||||
Py_ssize_t immortal_size = 0, mortal_size = 0;
|
Py_ssize_t immortal_size = 0, mortal_size = 0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -15688,9 +15686,9 @@ unicode_release_interned(void)
|
||||||
_PyUnicode_STATE(s).interned = SSTATE_NOT_INTERNED;
|
_PyUnicode_STATE(s).interned = SSTATE_NOT_INTERNED;
|
||||||
}
|
}
|
||||||
#ifdef INTERNED_STATS
|
#ifdef INTERNED_STATS
|
||||||
fprintf(stderr, "total size of all interned strings: "
|
fprintf(stderr,
|
||||||
"%" PY_FORMAT_SIZE_T "d/%" PY_FORMAT_SIZE_T "d "
|
"total size of all interned strings: %zd/%zd mortal/immortal\n",
|
||||||
"mortal/immortal\n", mortal_size, immortal_size);
|
mortal_size, immortal_size);
|
||||||
#endif
|
#endif
|
||||||
Py_DECREF(keys);
|
Py_DECREF(keys);
|
||||||
PyDict_Clear(interned);
|
PyDict_Clear(interned);
|
||||||
|
|
|
@ -452,7 +452,7 @@ seterror(Py_ssize_t iarg, const char *msg, int *levels, const char *fname,
|
||||||
}
|
}
|
||||||
if (iarg != 0) {
|
if (iarg != 0) {
|
||||||
PyOS_snprintf(p, sizeof(buf) - (p - buf),
|
PyOS_snprintf(p, sizeof(buf) - (p - buf),
|
||||||
"argument %" PY_FORMAT_SIZE_T "d", iarg);
|
"argument %zd", iarg);
|
||||||
i = 0;
|
i = 0;
|
||||||
p += strlen(p);
|
p += strlen(p);
|
||||||
while (i < 32 && levels[i] > 0 && (int)(p-buf) < 220) {
|
while (i < 32 && levels[i] > 0 && (int)(p-buf) < 220) {
|
||||||
|
@ -540,15 +540,14 @@ converttuple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
levels[0] = 0;
|
levels[0] = 0;
|
||||||
if (toplevel) {
|
if (toplevel) {
|
||||||
PyOS_snprintf(msgbuf, bufsize,
|
PyOS_snprintf(msgbuf, bufsize,
|
||||||
"expected %d argument%s, not %" PY_FORMAT_SIZE_T "d",
|
"expected %d argument%s, not %zd",
|
||||||
n,
|
n,
|
||||||
n == 1 ? "" : "s",
|
n == 1 ? "" : "s",
|
||||||
len);
|
len);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PyOS_snprintf(msgbuf, bufsize,
|
PyOS_snprintf(msgbuf, bufsize,
|
||||||
"must be sequence of length %d, "
|
"must be sequence of length %d, not %zd",
|
||||||
"not %" PY_FORMAT_SIZE_T "d",
|
|
||||||
n, len);
|
n, len);
|
||||||
}
|
}
|
||||||
return msgbuf;
|
return msgbuf;
|
||||||
|
|
|
@ -200,18 +200,14 @@ void
|
||||||
_PyHash_Fini(void)
|
_PyHash_Fini(void)
|
||||||
{
|
{
|
||||||
#ifdef Py_HASH_STATS
|
#ifdef Py_HASH_STATS
|
||||||
int i;
|
|
||||||
Py_ssize_t total = 0;
|
|
||||||
const char *fmt = "%2i %8" PY_FORMAT_SIZE_T "d %8" PY_FORMAT_SIZE_T "d\n";
|
|
||||||
|
|
||||||
fprintf(stderr, "len calls total\n");
|
fprintf(stderr, "len calls total\n");
|
||||||
for (i = 1; i <= Py_HASH_STATS_MAX; i++) {
|
Py_ssize_t total = 0;
|
||||||
|
for (int i = 1; i <= Py_HASH_STATS_MAX; i++) {
|
||||||
total += hashstats[i];
|
total += hashstats[i];
|
||||||
fprintf(stderr, fmt, i, hashstats[i], total);
|
fprintf(stderr, "%2i %8zd %8zd\n", i, hashstats[i], total);
|
||||||
}
|
}
|
||||||
total += hashstats[0];
|
total += hashstats[0];
|
||||||
fprintf(stderr, "> %8" PY_FORMAT_SIZE_T "d %8" PY_FORMAT_SIZE_T "d\n",
|
fprintf(stderr, "> %8zd %8zd\n", hashstats[0], total);
|
||||||
hashstats[0], total);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue