diff options
| author | Serhiy Storchaka <storchaka@gmail.com> | 2020-05-26 15:43:38 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-26 15:43:38 (GMT) |
| commit | 578c3955e0222ec7b3146197467fbb0fcfae12fe (patch) | |
| tree | 1314ca1eb6153feaf3fb1cae341784270ce24c32 /Python/clinic | |
| parent | 8ad052464a4e0aef9a11663b80f187087b773592 (diff) | |
| download | cpython-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 'Python/clinic')
| -rw-r--r-- | Python/clinic/_warnings.c.h | 7 | ||||
| -rw-r--r-- | Python/clinic/bltinmodule.c.h | 27 | ||||
| -rw-r--r-- | Python/clinic/import.c.h | 7 | ||||
| -rw-r--r-- | Python/clinic/marshal.c.h | 12 | ||||
| -rw-r--r-- | Python/clinic/sysmodule.c.h | 27 | ||||
| -rw-r--r-- | Python/clinic/traceback.c.h | 12 |
6 files changed, 6 insertions, 86 deletions
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 @@ warnings_warn(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec } } 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 @@ skip_optional_pos: 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 @@ builtin_chr(PyObject *module, PyObject *arg) 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 @@ builtin_compile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj 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 @@ builtin_compile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj } } 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 @@ builtin_compile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj } } 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 @@ skip_optional_pos: 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 @@ builtin_issubclass(PyObject *module, PyObject *const *args, Py_ssize_t nargs) 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 @@ _imp_source_hash(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyOb 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 @@ exit: #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 @@ marshal_dump(PyObject *module, 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; - } version = _PyLong_AsInt(args[2]); if (version == -1 && PyErr_Occurred()) { goto exit; @@ -111,11 +106,6 @@ marshal_dumps(PyObject *module, PyObject *const *args, Py_ssize_t nargs) 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 @@ exit: 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 @@ sys_setrecursionlimit(PyObject *module, PyObject *arg) 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 @@ sys_set_coroutine_origin_tracking_depth(PyObject *module, PyObject *const *args, 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 @@ sys_setdlopenflags(PyObject *module, PyObject *arg) 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 @@ sys_mdebug(PyObject *module, PyObject *arg) 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 @@ sys__getframe(PyObject *module, 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; - } depth = _PyLong_AsInt(args[0]); if (depth == -1 && PyErr_Occurred()) { goto exit; @@ -970,4 +945,4 @@ sys_getandroidapilevel(PyObject *module, PyObject *Py_UNUSED(ignored)) #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 @@ tb_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) 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 @@ tb_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=3def6c06248feed8 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=403778d7af5ebef9 input=a9049054013a1b77]*/ |
