mirror of
https://github.com/python/cpython.git
synced 2025-08-02 08:02:56 +00:00
bpo-29695: Deprecated using bad named keyword arguments in builtings: (#486)
int(), bool(), float(), list() and tuple(). Specify the value as a positional argument instead.
This commit is contained in:
parent
d31b28e16a
commit
58d23e6806
12 changed files with 65 additions and 2 deletions
|
@ -48,6 +48,12 @@ bool_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:bool", kwlist, &x))
|
||||
return NULL;
|
||||
if (kwds != NULL && PyDict_GET_SIZE(kwds) != 0) {
|
||||
if (PyErr_Warn(PyExc_DeprecationWarning,
|
||||
"Using 'x' as a keyword argument is deprecated; "
|
||||
"specify the value as a positional argument instead") < 0)
|
||||
return NULL;
|
||||
}
|
||||
ok = PyObject_IsTrue(x);
|
||||
if (ok < 0)
|
||||
return NULL;
|
||||
|
|
|
@ -1569,6 +1569,12 @@ float_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
return float_subtype_new(type, args, kwds); /* Wimp out */
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:float", kwlist, &x))
|
||||
return NULL;
|
||||
if (kwds != NULL && PyDict_GET_SIZE(kwds) != 0) {
|
||||
if (PyErr_Warn(PyExc_DeprecationWarning,
|
||||
"Using 'x' as a keyword argument is deprecated; "
|
||||
"specify the value as a positional argument instead") < 0)
|
||||
return NULL;
|
||||
}
|
||||
/* If it's a string, but not a string subclass, use
|
||||
PyFloat_FromString. */
|
||||
if (PyUnicode_CheckExact(x))
|
||||
|
|
|
@ -2297,6 +2297,12 @@ list_init(PyListObject *self, PyObject *args, PyObject *kw)
|
|||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "|O:list", kwlist, &arg))
|
||||
return -1;
|
||||
if (arg != NULL && PyTuple_GET_SIZE(args) == 0) {
|
||||
if (PyErr_Warn(PyExc_DeprecationWarning,
|
||||
"Using 'sequence' as a keyword argument is deprecated; "
|
||||
"specify the value as a positional argument instead") < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Verify list invariants established by PyType_GenericAlloc() */
|
||||
assert(0 <= Py_SIZE(self));
|
||||
|
|
|
@ -4811,6 +4811,12 @@ long_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
}
|
||||
return PyLong_FromLong(0L);
|
||||
}
|
||||
if (PyTuple_GET_SIZE(args) == 0) {
|
||||
if (PyErr_Warn(PyExc_DeprecationWarning,
|
||||
"Using 'x' as a keyword argument is deprecated; "
|
||||
"specify the value as a positional argument instead") < 0)
|
||||
return NULL;
|
||||
}
|
||||
if (obase == NULL)
|
||||
return PyNumber_Long(x);
|
||||
|
||||
|
|
|
@ -654,6 +654,12 @@ tuple_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
return tuple_subtype_new(type, args, kwds);
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:tuple", kwlist, &arg))
|
||||
return NULL;
|
||||
if (arg != NULL && PyTuple_GET_SIZE(args) == 0) {
|
||||
if (PyErr_Warn(PyExc_DeprecationWarning,
|
||||
"Using 'sequence' as a keyword argument is deprecated; "
|
||||
"specify the value as a positional argument instead") < 0)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (arg == NULL)
|
||||
return PyTuple_New(0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue