Skip to content

Commit 149c693

Browse files
authored
Fix format strings on 32bit platforms (#1226)
1 parent ae6ed08 commit 149c693

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

CHANGES/1225.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1226.bugfix.rst

CHANGES/1226.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed format string compilation errors in debug builds on 32-bit platforms by using portable ``%zd`` format specifiers for ``Py_ssize_t`` values instead of ``%ld`` -- by :user:`bdraco`.

multidict/_multilib/hashtable.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1963,15 +1963,15 @@ static inline int
19631963
_md_dump(MultiDictObject *md)
19641964
{
19651965
htkeys_t *keys = md->keys;
1966-
printf("Dump %p [%ld from %ld usable %ld nentries %ld]\n",
1966+
printf("Dump %p [%zd from %zd usable %zd nentries %zd]\n",
19671967
(void *)md,
19681968
md->used,
19691969
htkeys_nslots(keys),
19701970
keys->usable,
19711971
keys->nentries);
19721972
for (Py_ssize_t i = 0; i < htkeys_nslots(keys); i++) {
19731973
Py_ssize_t ix = htkeys_get_index(keys, i);
1974-
printf(" %ld -> %ld\n", i, ix);
1974+
printf(" %zd -> %zd\n", i, ix);
19751975
}
19761976
printf(" --------\n");
19771977
entry_t *entries = htkeys_entries(keys);
@@ -1980,9 +1980,9 @@ _md_dump(MultiDictObject *md)
19801980
PyObject *identity = entry->identity;
19811981

19821982
if (identity == NULL) {
1983-
printf(" %ld [deleted]\n", i);
1983+
printf(" %zd [deleted]\n", i);
19841984
} else {
1985-
printf(" %ld h=%20ld, i=\'", i, entry->hash);
1985+
printf(" %zd h=%20zd, i=\'", i, entry->hash);
19861986
PyObject_Print(entry->identity, stdout, Py_PRINT_RAW);
19871987
printf("\', k=\'");
19881988
PyObject_Print(entry->key, stdout, Py_PRINT_RAW);

0 commit comments

Comments
 (0)