Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 14 additions & 46 deletions Lib/test/clinic.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1652,32 +1652,16 @@ test_Py_ssize_t_converter(PyObject *module, PyObject *const *args, Py_ssize_t na
if (nargs < 1) {
goto skip_optional;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = _PyNumber_Index(args[0]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
a = ival;
a = PyNumber_AsSsize_t(args[0], PyExc_OverflowError);
if (a == -1 && PyErr_Occurred()) {
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = _PyNumber_Index(args[1]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
b = ival;
b = PyNumber_AsSsize_t(args[1], PyExc_OverflowError);
if (b == -1 && PyErr_Occurred()) {
goto exit;
}
if (nargs < 3) {
goto skip_optional;
Expand All @@ -1688,23 +1672,15 @@ test_Py_ssize_t_converter(PyObject *module, PyObject *const *args, Py_ssize_t na
if (nargs < 4) {
goto skip_optional;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = _PyNumber_Index(args[3]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
d = ival;
d = PyNumber_AsSsize_t(args[3], PyExc_OverflowError);
if (d == -1 && PyErr_Occurred()) {
goto exit;
}
if (d < 0) {
PyErr_SetString(PyExc_ValueError,
"d cannot be negative");
goto exit;
}
}
if (nargs < 5) {
goto skip_optional;
}
Expand All @@ -1714,17 +1690,9 @@ test_Py_ssize_t_converter(PyObject *module, PyObject *const *args, Py_ssize_t na
if (nargs < 6) {
goto skip_optional;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = _PyNumber_Index(args[5]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
f = ival;
f = PyNumber_AsSsize_t(args[5], PyExc_OverflowError);
if (f == -1 && PyErr_Occurred()) {
goto exit;
}
if (nargs < 7) {
goto skip_optional;
Expand All @@ -1743,7 +1711,7 @@ static PyObject *
test_Py_ssize_t_converter_impl(PyObject *module, Py_ssize_t a, Py_ssize_t b,
Py_ssize_t c, Py_ssize_t d, Py_ssize_t e,
Py_ssize_t f, Py_ssize_t g)
/*[clinic end generated code: output=4ae0a56a1447fba9 input=a25bac8ecf2890aa]*/
/*[clinic end generated code: output=4f744bf0d897e01c input=a25bac8ecf2890aa]*/


/*[clinic input]
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_zlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,11 @@ def test_decompressobj_badflush(self):

@support.cpython_only
def test_overflow(self):
with self.assertRaisesRegex(OverflowError, 'int too large'):
with self.assertRaisesRegex(OverflowError, "cannot fit 'int'"):
zlib.decompress(b'', 15, sys.maxsize + 1)
with self.assertRaisesRegex(OverflowError, 'int too large'):
with self.assertRaisesRegex(OverflowError, "cannot fit 'int'"):
zlib.decompressobj().decompress(b'', sys.maxsize + 1)
with self.assertRaisesRegex(OverflowError, 'int too large'):
with self.assertRaisesRegex(OverflowError, "cannot fit 'int'"):
zlib.decompressobj().flush(sys.maxsize + 1)

@support.cpython_only
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Speed up conversion of :class:`int` arguments to ``Py_ssize_t`` in functions
using Argument Clinic or the ``n`` format unit of :c:func:`PyArg_ParseTuple`.
When the value does not fit, the :exc:`OverflowError` message is now
``cannot fit 'int' into an index-sized integer``.
35 changes: 9 additions & 26 deletions Modules/_ctypes/clinic/_ctypes.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 7 additions & 24 deletions Modules/_ctypes/clinic/callproc.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 10 additions & 35 deletions Modules/_ctypes/clinic/cfield.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading