diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2021-09-07 12:18:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-07 12:18:46 (GMT) |
commit | 8ca6b61e3fd7f1e2876126cee82da8d812c8462f (patch) | |
tree | d3f55761ad4c4cbac8db1814e5d11a0b7c24e7b2 /Modules/_struct.c | |
parent | 97b754d4b46ad9dd63f68906484f805931578c81 (diff) | |
download | cpython-8ca6b61e3fd7f1e2876126cee82da8d812c8462f.zip cpython-8ca6b61e3fd7f1e2876126cee82da8d812c8462f.tar.gz cpython-8ca6b61e3fd7f1e2876126cee82da8d812c8462f.tar.bz2 |
bpo-45034: Fix how upper limit is formatted for `struct.pack("H", ...)` (GH-28178)
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Modules/_struct.c')
-rw-r--r-- | Modules/_struct.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Modules/_struct.c b/Modules/_struct.c index 30ad9f2..872c30d 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -589,9 +589,9 @@ np_short(_structmodulestate *state, char *p, PyObject *v, const formatdef *f) if (get_long(state, v, &x) < 0) return -1; if (x < SHRT_MIN || x > SHRT_MAX) { - PyErr_SetString(state->StructError, - "short format requires " Py_STRINGIFY(SHRT_MIN) - " <= number <= " Py_STRINGIFY(SHRT_MAX)); + PyErr_Format(state->StructError, + "short format requires %d <= number <= %d", + (int)SHRT_MIN, (int)SHRT_MAX); return -1; } y = (short)x; @@ -607,9 +607,9 @@ np_ushort(_structmodulestate *state, char *p, PyObject *v, const formatdef *f) if (get_long(state, v, &x) < 0) return -1; if (x < 0 || x > USHRT_MAX) { - PyErr_SetString(state->StructError, - "ushort format requires 0 <= number <= " - Py_STRINGIFY(USHRT_MAX)); + PyErr_Format(state->StructError, + "ushort format requires 0 <= number <= %u", + (unsigned int)USHRT_MAX); return -1; } y = (unsigned short)x; |