summaryrefslogtreecommitdiffstats
path: root/Objects/clinic
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2020-05-26 15:43:38 (GMT)
committerGitHub <noreply@github.com>2020-05-26 15:43:38 (GMT)
commit578c3955e0222ec7b3146197467fbb0fcfae12fe (patch)
tree1314ca1eb6153feaf3fb1cae341784270ce24c32 /Objects/clinic
parent8ad052464a4e0aef9a11663b80f187087b773592 (diff)
downloadcpython-578c3955e0222ec7b3146197467fbb0fcfae12fe.zip
cpython-578c3955e0222ec7b3146197467fbb0fcfae12fe.tar.gz
cpython-578c3955e0222ec7b3146197467fbb0fcfae12fe.tar.bz2
bpo-37999: No longer use __int__ in implicit integer conversions. (GH-15636)
Only __index__ should be used to make integer conversions lossless.
Diffstat (limited to 'Objects/clinic')
-rw-r--r--Objects/clinic/bytearrayobject.c.h42
-rw-r--r--Objects/clinic/bytesobject.c.h27
-rw-r--r--Objects/clinic/codeobject.c.h37
-rw-r--r--Objects/clinic/listobject.c.h17
-rw-r--r--Objects/clinic/longobject.c.h7
-rw-r--r--Objects/clinic/memoryobject.c.h7
-rw-r--r--Objects/clinic/typeobject.c.h7
-rw-r--r--Objects/clinic/unicodeobject.c.h47
8 files changed, 8 insertions, 183 deletions
diff --git a/Objects/clinic/bytearrayobject.c.h b/Objects/clinic/bytearrayobject.c.h
index 35ba1ff..83b0d03 100644
--- a/Objects/clinic/bytearrayobject.c.h
+++ b/Objects/clinic/bytearrayobject.c.h
@@ -268,11 +268,6 @@ bytearray_replace(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nar
if (nargs < 3) {
goto skip_optional;
}
- if (PyFloat_Check(args[2])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[2]);
@@ -346,11 +341,6 @@ bytearray_split(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs
goto skip_optional_pos;
}
}
- if (PyFloat_Check(args[1])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[1]);
@@ -450,11 +440,6 @@ bytearray_rsplit(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t narg
goto skip_optional_pos;
}
}
- if (PyFloat_Check(args[1])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[1]);
@@ -519,11 +504,6 @@ bytearray_insert(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t narg
if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) {
goto exit;
}
- if (PyFloat_Check(args[0])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
@@ -617,11 +597,6 @@ bytearray_pop(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs)
if (nargs < 1) {
goto skip_optional;
}
- if (PyFloat_Check(args[0])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
@@ -896,11 +871,6 @@ bytearray_splitlines(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t
if (!noptargs) {
goto skip_optional_pos;
}
- if (PyFloat_Check(args[0])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
keepends = _PyLong_AsInt(args[0]);
if (keepends == -1 && PyErr_Occurred()) {
goto exit;
@@ -1000,11 +970,6 @@ bytearray_hex(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs,
goto skip_optional_pos;
}
}
- if (PyFloat_Check(args[1])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
bytes_per_sep = _PyLong_AsInt(args[1]);
if (bytes_per_sep == -1 && PyErr_Occurred()) {
goto exit;
@@ -1058,11 +1023,6 @@ bytearray_reduce_ex(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t n
if (nargs < 1) {
goto skip_optional;
}
- if (PyFloat_Check(args[0])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
proto = _PyLong_AsInt(args[0]);
if (proto == -1 && PyErr_Occurred()) {
goto exit;
@@ -1091,4 +1051,4 @@ bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored))
{
return bytearray_sizeof_impl(self);
}
-/*[clinic end generated code: output=b2919f76709e48dc input=a9049054013a1b77]*/
+/*[clinic end generated code: output=920748990279fb9d input=a9049054013a1b77]*/
diff --git a/Objects/clinic/bytesobject.c.h b/Objects/clinic/bytesobject.c.h
index 063a377..c4a2d0c 100644
--- a/Objects/clinic/bytesobject.c.h
+++ b/Objects/clinic/bytesobject.c.h
@@ -46,11 +46,6 @@ bytes_split(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs, PyObje
goto skip_optional_pos;
}
}
- if (PyFloat_Check(args[1])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[1]);
@@ -202,11 +197,6 @@ bytes_rsplit(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs, PyObj
goto skip_optional_pos;
}
}
- if (PyFloat_Check(args[1])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[1]);
@@ -493,11 +483,6 @@ bytes_replace(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs)
if (nargs < 3) {
goto skip_optional;
}
- if (PyFloat_Check(args[2])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[2]);
@@ -715,11 +700,6 @@ bytes_splitlines(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs, P
if (!noptargs) {
goto skip_optional_pos;
}
- if (PyFloat_Check(args[0])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
keepends = _PyLong_AsInt(args[0]);
if (keepends == -1 && PyErr_Occurred()) {
goto exit;
@@ -819,11 +799,6 @@ bytes_hex(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject
goto skip_optional_pos;
}
}
- if (PyFloat_Check(args[1])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
bytes_per_sep = _PyLong_AsInt(args[1]);
if (bytes_per_sep == -1 && PyErr_Occurred()) {
goto exit;
@@ -834,4 +809,4 @@ skip_optional_pos:
exit:
return return_value;
}
-/*[clinic end generated code: output=220388917d7bf751 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a0c31faea2671a8c input=a9049054013a1b77]*/
diff --git a/Objects/clinic/codeobject.c.h b/Objects/clinic/codeobject.c.h
index 1dd8227..aef505f 100644
--- a/Objects/clinic/codeobject.c.h
+++ b/Objects/clinic/codeobject.c.h
@@ -59,11 +59,6 @@ code_replace(PyCodeObject *self, PyObject *const *args, Py_ssize_t nargs, PyObje
goto skip_optional_kwonly;
}
if (args[0]) {
- if (PyFloat_Check(args[0])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
co_argcount = _PyLong_AsInt(args[0]);
if (co_argcount == -1 && PyErr_Occurred()) {
goto exit;
@@ -73,11 +68,6 @@ code_replace(PyCodeObject *self, PyObject *const *args, Py_ssize_t nargs, PyObje
}
}
if (args[1]) {
- if (PyFloat_Check(args[1])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
co_posonlyargcount = _PyLong_AsInt(args[1]);
if (co_posonlyargcount == -1 && PyErr_Occurred()) {
goto exit;
@@ -87,11 +77,6 @@ code_replace(PyCodeObject *self, PyObject *const *args, Py_ssize_t nargs, PyObje
}
}
if (args[2]) {
- if (PyFloat_Check(args[2])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
co_kwonlyargcount = _PyLong_AsInt(args[2]);
if (co_kwonlyargcount == -1 && PyErr_Occurred()) {
goto exit;
@@ -101,11 +86,6 @@ code_replace(PyCodeObject *self, PyObject *const *args, Py_ssize_t nargs, PyObje
}
}
if (args[3]) {
- if (PyFloat_Check(args[3])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
co_nlocals = _PyLong_AsInt(args[3]);
if (co_nlocals == -1 && PyErr_Occurred()) {
goto exit;
@@ -115,11 +95,6 @@ code_replace(PyCodeObject *self, PyObject *const *args, Py_ssize_t nargs, PyObje
}
}
if (args[4]) {
- if (PyFloat_Check(args[4])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
co_stacksize = _PyLong_AsInt(args[4]);
if (co_stacksize == -1 && PyErr_Occurred()) {
goto exit;
@@ -129,11 +104,6 @@ code_replace(PyCodeObject *self, PyObject *const *args, Py_ssize_t nargs, PyObje
}
}
if (args[5]) {
- if (PyFloat_Check(args[5])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
co_flags = _PyLong_AsInt(args[5]);
if (co_flags == -1 && PyErr_Occurred()) {
goto exit;
@@ -143,11 +113,6 @@ code_replace(PyCodeObject *self, PyObject *const *args, Py_ssize_t nargs, PyObje
}
}
if (args[6]) {
- if (PyFloat_Check(args[6])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
co_firstlineno = _PyLong_AsInt(args[6]);
if (co_firstlineno == -1 && PyErr_Occurred()) {
goto exit;
@@ -253,4 +218,4 @@ skip_optional_kwonly:
exit:
return return_value;
}
-/*[clinic end generated code: output=27fe34e82106b220 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=f9f23e912a3955b9 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/listobject.c.h b/Objects/clinic/listobject.c.h
index ed137c9..82884a4 100644
--- a/Objects/clinic/listobject.c.h
+++ b/Objects/clinic/listobject.c.h
@@ -24,11 +24,6 @@ list_insert(PyListObject *self, PyObject *const *args, Py_ssize_t nargs)
if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) {
goto exit;
}
- if (PyFloat_Check(args[0])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
@@ -128,11 +123,6 @@ list_pop(PyListObject *self, PyObject *const *args, Py_ssize_t nargs)
if (nargs < 1) {
goto skip_optional;
}
- if (PyFloat_Check(args[0])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
@@ -196,11 +186,6 @@ list_sort(PyListObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject
goto skip_optional_kwonly;
}
}
- if (PyFloat_Check(args[1])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
reverse = _PyLong_AsInt(args[1]);
if (reverse == -1 && PyErr_Occurred()) {
goto exit;
@@ -367,4 +352,4 @@ list___reversed__(PyListObject *self, PyObject *Py_UNUSED(ignored))
{
return list___reversed___impl(self);
}
-/*[clinic end generated code: output=1ff61490c091d165 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=137db7b11196b581 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/longobject.c.h b/Objects/clinic/longobject.c.h
index 27e8dfe..d3d5c19 100644
--- a/Objects/clinic/longobject.c.h
+++ b/Objects/clinic/longobject.c.h
@@ -209,11 +209,6 @@ int_to_bytes(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *
if (!args) {
goto exit;
}
- if (PyFloat_Check(args[0])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
@@ -313,4 +308,4 @@ skip_optional_kwonly:
exit:
return return_value;
}
-/*[clinic end generated code: output=77bc3b2615822cb8 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=46d40c8aa6d420b7 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/memoryobject.c.h b/Objects/clinic/memoryobject.c.h
index 75ac201..8227f0e 100644
--- a/Objects/clinic/memoryobject.c.h
+++ b/Objects/clinic/memoryobject.c.h
@@ -56,11 +56,6 @@ memoryview_hex(PyMemoryViewObject *self, PyObject *const *args, Py_ssize_t nargs
goto skip_optional_pos;
}
}
- if (PyFloat_Check(args[1])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
bytes_per_sep = _PyLong_AsInt(args[1]);
if (bytes_per_sep == -1 && PyErr_Occurred()) {
goto exit;
@@ -71,4 +66,4 @@ skip_optional_pos:
exit:
return return_value;
}
-/*[clinic end generated code: output=ee265a73f68b0077 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=91106ef704134b19 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/typeobject.c.h b/Objects/clinic/typeobject.c.h
index 357eb44..8c70d76 100644
--- a/Objects/clinic/typeobject.c.h
+++ b/Objects/clinic/typeobject.c.h
@@ -166,11 +166,6 @@ object___reduce_ex__(PyObject *self, PyObject *arg)
PyObject *return_value = NULL;
int protocol;
- if (PyFloat_Check(arg)) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
protocol = _PyLong_AsInt(arg);
if (protocol == -1 && PyErr_Occurred()) {
goto exit;
@@ -248,4 +243,4 @@ object___dir__(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return object___dir___impl(self);
}
-/*[clinic end generated code: output=7a6d272d282308f3 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=b4fb62939b08baf9 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/unicodeobject.c.h b/Objects/clinic/unicodeobject.c.h
index cf81df4..2d81730 100644
--- a/Objects/clinic/unicodeobject.c.h
+++ b/Objects/clinic/unicodeobject.c.h
@@ -86,11 +86,6 @@ unicode_center(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
if (!_PyArg_CheckPositional("center", nargs, 1, 2)) {
goto exit;
}
- if (PyFloat_Check(args[0])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
@@ -224,11 +219,6 @@ unicode_expandtabs(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyOb
if (!noptargs) {
goto skip_optional_pos;
}
- if (PyFloat_Check(args[0])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
tabsize = _PyLong_AsInt(args[0]);
if (tabsize == -1 && PyErr_Occurred()) {
goto exit;
@@ -530,11 +520,6 @@ unicode_ljust(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
if (!_PyArg_CheckPositional("ljust", nargs, 1, 2)) {
goto exit;
}
- if (PyFloat_Check(args[0])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
@@ -730,11 +715,6 @@ unicode_replace(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
if (nargs < 3) {
goto skip_optional;
}
- if (PyFloat_Check(args[2])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[2]);
@@ -849,11 +829,6 @@ unicode_rjust(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
if (!_PyArg_CheckPositional("rjust", nargs, 1, 2)) {
goto exit;
}
- if (PyFloat_Check(args[0])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
@@ -923,11 +898,6 @@ unicode_split(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject
goto skip_optional_pos;
}
}
- if (PyFloat_Check(args[1])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[1]);
@@ -1025,11 +995,6 @@ unicode_rsplit(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject
goto skip_optional_pos;
}
}
- if (PyFloat_Check(args[1])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[1]);
@@ -1081,11 +1046,6 @@ unicode_splitlines(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyOb
if (!noptargs) {
goto skip_optional_pos;
}
- if (PyFloat_Check(args[0])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
keepends = _PyLong_AsInt(args[0]);
if (keepends == -1 && PyErr_Occurred()) {
goto exit;
@@ -1231,11 +1191,6 @@ unicode_zfill(PyObject *self, PyObject *arg)
PyObject *return_value = NULL;
Py_ssize_t width;
- if (PyFloat_Check(arg)) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(arg);
@@ -1303,4 +1258,4 @@ unicode_sizeof(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return unicode_sizeof_impl(self);
}
-/*[clinic end generated code: output=b91233f3722643be input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ea1aff10c743be14 input=a9049054013a1b77]*/