bpo-37999: No longer use __int__ in implicit integer conversions. (GH-15636)
Only __index__ should be used to make integer conversions lossless.
diff --git a/Python/clinic/_warnings.c.h b/Python/clinic/_warnings.c.h
index 67ab0e3..80ed2ae 100644
--- a/Python/clinic/_warnings.c.h
+++ b/Python/clinic/_warnings.c.h
@@ -43,11 +43,6 @@
}
}
if (args[2]) {
- 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]);
@@ -71,4 +66,4 @@
exit:
return return_value;
}
-/*[clinic end generated code: output=b7bb54c73b5433ec input=a9049054013a1b77]*/
+/*[clinic end generated code: output=484e5ffe94edf0f0 input=a9049054013a1b77]*/
diff --git a/Python/clinic/bltinmodule.c.h b/Python/clinic/bltinmodule.c.h
index d15af1f..377afde 100644
--- a/Python/clinic/bltinmodule.c.h
+++ b/Python/clinic/bltinmodule.c.h
@@ -134,11 +134,6 @@
PyObject *return_value = NULL;
int i;
- if (PyFloat_Check(arg)) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
i = _PyLong_AsInt(arg);
if (i == -1 && PyErr_Occurred()) {
goto exit;
@@ -216,11 +211,6 @@
goto skip_optional_pos;
}
if (args[3]) {
- if (PyFloat_Check(args[3])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
flags = _PyLong_AsInt(args[3]);
if (flags == -1 && PyErr_Occurred()) {
goto exit;
@@ -230,11 +220,6 @@
}
}
if (args[4]) {
- if (PyFloat_Check(args[4])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
dont_inherit = _PyLong_AsInt(args[4]);
if (dont_inherit == -1 && PyErr_Occurred()) {
goto exit;
@@ -244,11 +229,6 @@
}
}
if (args[5]) {
- if (PyFloat_Check(args[5])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
optimize = _PyLong_AsInt(args[5]);
if (optimize == -1 && PyErr_Occurred()) {
goto exit;
@@ -261,11 +241,6 @@
if (!noptargs) {
goto skip_optional_kwonly;
}
- if (PyFloat_Check(args[6])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
feature_version = _PyLong_AsInt(args[6]);
if (feature_version == -1 && PyErr_Occurred()) {
goto exit;
@@ -855,4 +830,4 @@
exit:
return return_value;
}
-/*[clinic end generated code: output=29686a89b739d600 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=780fd9712ec6a6db input=a9049054013a1b77]*/
diff --git a/Python/clinic/import.c.h b/Python/clinic/import.c.h
index e4867f3..4e013cc 100644
--- a/Python/clinic/import.c.h
+++ b/Python/clinic/import.c.h
@@ -420,11 +420,6 @@
if (!args) {
goto exit;
}
- if (PyFloat_Check(args[0])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
key = PyLong_AsLong(args[0]);
if (key == -1 && PyErr_Occurred()) {
goto exit;
@@ -454,4 +449,4 @@
#ifndef _IMP_EXEC_DYNAMIC_METHODDEF
#define _IMP_EXEC_DYNAMIC_METHODDEF
#endif /* !defined(_IMP_EXEC_DYNAMIC_METHODDEF) */
-/*[clinic end generated code: output=3dc495e9c64d944e input=a9049054013a1b77]*/
+/*[clinic end generated code: output=7c31c433af88af6b input=a9049054013a1b77]*/
diff --git a/Python/clinic/marshal.c.h b/Python/clinic/marshal.c.h
index 05d4830..f80d5ef 100644
--- a/Python/clinic/marshal.c.h
+++ b/Python/clinic/marshal.c.h
@@ -42,11 +42,6 @@
if (nargs < 3) {
goto skip_optional;
}
- if (PyFloat_Check(args[2])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
version = _PyLong_AsInt(args[2]);
if (version == -1 && PyErr_Occurred()) {
goto exit;
@@ -111,11 +106,6 @@
if (nargs < 2) {
goto skip_optional;
}
- if (PyFloat_Check(args[1])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
version = _PyLong_AsInt(args[1]);
if (version == -1 && PyErr_Occurred()) {
goto exit;
@@ -165,4 +155,4 @@
return return_value;
}
-/*[clinic end generated code: output=a859dabe8b0afeb6 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=68b78f38bfe0c06d input=a9049054013a1b77]*/
diff --git a/Python/clinic/sysmodule.c.h b/Python/clinic/sysmodule.c.h
index 4615eba..c1a9a2d 100644
--- a/Python/clinic/sysmodule.c.h
+++ b/Python/clinic/sysmodule.c.h
@@ -372,11 +372,6 @@
PyObject *return_value = NULL;
int new_limit;
- if (PyFloat_Check(arg)) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
new_limit = _PyLong_AsInt(arg);
if (new_limit == -1 && PyErr_Occurred()) {
goto exit;
@@ -417,11 +412,6 @@
if (!args) {
goto exit;
}
- if (PyFloat_Check(args[0])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
depth = _PyLong_AsInt(args[0]);
if (depth == -1 && PyErr_Occurred()) {
goto exit;
@@ -590,11 +580,6 @@
PyObject *return_value = NULL;
int new_val;
- if (PyFloat_Check(arg)) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
new_val = _PyLong_AsInt(arg);
if (new_val == -1 && PyErr_Occurred()) {
goto exit;
@@ -650,11 +635,6 @@
PyObject *return_value = NULL;
int flag;
- if (PyFloat_Check(arg)) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
flag = _PyLong_AsInt(arg);
if (flag == -1 && PyErr_Occurred()) {
goto exit;
@@ -790,11 +770,6 @@
if (nargs < 1) {
goto skip_optional;
}
- if (PyFloat_Check(args[0])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
depth = _PyLong_AsInt(args[0]);
if (depth == -1 && PyErr_Occurred()) {
goto exit;
@@ -970,4 +945,4 @@
#ifndef SYS_GETANDROIDAPILEVEL_METHODDEF
#define SYS_GETANDROIDAPILEVEL_METHODDEF
#endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */
-/*[clinic end generated code: output=39eb34a01fb9a919 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=87baa3357293ea65 input=a9049054013a1b77]*/
diff --git a/Python/clinic/traceback.c.h b/Python/clinic/traceback.c.h
index 04daf2a..404a0c4 100644
--- a/Python/clinic/traceback.c.h
+++ b/Python/clinic/traceback.c.h
@@ -36,20 +36,10 @@
goto exit;
}
tb_frame = (PyFrameObject *)fastargs[1];
- if (PyFloat_Check(fastargs[2])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
tb_lasti = _PyLong_AsInt(fastargs[2]);
if (tb_lasti == -1 && PyErr_Occurred()) {
goto exit;
}
- if (PyFloat_Check(fastargs[3])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
tb_lineno = _PyLong_AsInt(fastargs[3]);
if (tb_lineno == -1 && PyErr_Occurred()) {
goto exit;
@@ -59,4 +49,4 @@
exit:
return return_value;
}
-/*[clinic end generated code: output=3def6c06248feed8 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=403778d7af5ebef9 input=a9049054013a1b77]*/