Commit fca2e075 authored by Lisandro Dalcin's avatar Lisandro Dalcin

Use PY_FORMAT_SIZE_T in PyErr_Format() calls

parent 283fbb05
...@@ -968,8 +968,8 @@ static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { ...@@ -968,8 +968,8 @@ static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
offset = ctx->head->parent_offset + field->offset; offset = ctx->head->parent_offset + field->offset;
if (ctx->fmt_offset != offset) { if (ctx->fmt_offset != offset) {
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"Buffer dtype mismatch; next field is at offset %"PY_FORMAT_SIZE_T"d " "Buffer dtype mismatch; next field is at offset %"PY_FORMAT_SIZE_T"d but %"PY_FORMAT_SIZE_T"d expected",
"but %"PY_FORMAT_SIZE_T"d expected", (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset); (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset);
return -1; return -1;
} }
...@@ -1161,8 +1161,7 @@ static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* ob ...@@ -1161,8 +1161,7 @@ static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* ob
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"Item size of buffer (%"PY_FORMAT_SIZE_T"d byte%s) does not match size of '%s' (%"PY_FORMAT_SIZE_T"d byte%s)", "Item size of buffer (%"PY_FORMAT_SIZE_T"d byte%s) does not match size of '%s' (%"PY_FORMAT_SIZE_T"d byte%s)",
buf->itemsize, (buf->itemsize > 1) ? "s" : "", buf->itemsize, (buf->itemsize > 1) ? "s" : "",
dtype->name, dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : "");
(Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : "");
goto fail; goto fail;
} }
if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
......
...@@ -8506,11 +8506,7 @@ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); ...@@ -8506,11 +8506,7 @@ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
impl = ''' impl = '''
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
#if PY_VERSION_HEX < 0x02050000 "too many values to unpack (expected %"PY_FORMAT_SIZE_T"d)", expected);
"too many values to unpack (expected %d)", (int)expected);
#else
"too many values to unpack (expected %zd)", expected);
#endif
} }
''') ''')
...@@ -8521,12 +8517,8 @@ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); ...@@ -8521,12 +8517,8 @@ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
impl = ''' impl = '''
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
#if PY_VERSION_HEX < 0x02050000 "need more than %"PY_FORMAT_SIZE_T"d value%s to unpack",
"need more than %d value%s to unpack", (int)index, index, (index == 1) ? "" : "s");
#else
"need more than %zd value%s to unpack", index,
#endif
(index == 1) ? "" : "s");
} }
''') ''')
......
...@@ -6936,7 +6936,7 @@ static void __Pyx_RaiseArgtupleInvalid( ...@@ -6936,7 +6936,7 @@ static void __Pyx_RaiseArgtupleInvalid(
Py_ssize_t num_found) Py_ssize_t num_found)
{ {
Py_ssize_t num_expected; Py_ssize_t num_expected;
const char *number, *more_or_less; const char *more_or_less;
if (num_found < num_min) { if (num_found < num_min) {
num_expected = num_min; num_expected = num_min;
...@@ -6948,14 +6948,10 @@ static void __Pyx_RaiseArgtupleInvalid( ...@@ -6948,14 +6948,10 @@ static void __Pyx_RaiseArgtupleInvalid(
if (exact) { if (exact) {
more_or_less = "exactly"; more_or_less = "exactly";
} }
number = (num_expected == 1) ? "" : "s";
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
#if PY_VERSION_HEX < 0x02050000 "%s() takes %s %"PY_FORMAT_SIZE_T"d positional argument%s (%"PY_FORMAT_SIZE_T"d given)",
"%s() takes %s %d positional argument%s (%d given)", func_name, more_or_less, num_expected,
#else (num_expected == 1) ? "" : "s", num_found);
"%s() takes %s %zd positional argument%s (%zd given)",
#endif
func_name, more_or_less, num_expected, number, num_found);
} }
""") """)
......
...@@ -997,13 +997,8 @@ static CYTHON_INLINE Py_UCS4 __Pyx_PyObject_AsPy_UCS4(PyObject* x) { ...@@ -997,13 +997,8 @@ static CYTHON_INLINE Py_UCS4 __Pyx_PyObject_AsPy_UCS4(PyObject* x) {
} }
#endif #endif
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"only single character unicode strings can be converted to Py_UCS4, got length " "only single character unicode strings can be converted to Py_UCS4, "
#if PY_VERSION_HEX < 0x02050000 "got length %"PY_FORMAT_SIZE_T"d", PyUnicode_GET_SIZE(x));
"%d",
#else
"%zd",
#endif
PyUnicode_GET_SIZE(x));
return (Py_UCS4)-1; return (Py_UCS4)-1;
} }
ival = __Pyx_PyInt_AsLong(x); ival = __Pyx_PyInt_AsLong(x);
...@@ -1053,13 +1048,8 @@ static CYTHON_INLINE Py_UNICODE __Pyx_PyObject_AsPy_UNICODE(PyObject* x) { ...@@ -1053,13 +1048,8 @@ static CYTHON_INLINE Py_UNICODE __Pyx_PyObject_AsPy_UNICODE(PyObject* x) {
if (PyUnicode_Check(x)) { if (PyUnicode_Check(x)) {
if (unlikely(PyUnicode_GET_SIZE(x) != 1)) { if (unlikely(PyUnicode_GET_SIZE(x) != 1)) {
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"only single character unicode strings can be converted to Py_UNICODE, got length " "only single character unicode strings can be converted to Py_UNICODE, "
#if PY_VERSION_HEX < 0x02050000 "got length %"PY_FORMAT_SIZE_T"d", PyUnicode_GET_SIZE(x));
"%d",
#else
"%zd",
#endif
PyUnicode_GET_SIZE(x));
return (Py_UNICODE)-1; return (Py_UNICODE)-1;
} }
return PyUnicode_AS_UNICODE(x)[0]; return PyUnicode_AS_UNICODE(x)[0];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment