bpo-29695: Remove bad keyword parameters in int(), bool(), float(), list() and tuple(). (#518)
diff --git a/Objects/boolobject.c b/Objects/boolobject.c
index b54b052..becdfcb 100644
--- a/Objects/boolobject.c
+++ b/Objects/boolobject.c
@@ -42,18 +42,13 @@
static PyObject *
bool_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
- static char *kwlist[] = {"x", 0};
PyObject *x = Py_False;
long ok;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:bool", kwlist, &x))
+ if (!_PyArg_NoKeywords("bool()", kwds))
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 (!PyArg_UnpackTuple(args, "bool", 0, 1, &x))
+ return NULL;
ok = PyObject_IsTrue(x);
if (ok < 0)
return NULL;
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index 3a881c3..9267b9f 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -1563,18 +1563,13 @@
float_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
PyObject *x = Py_False; /* Integer zero */
- static char *kwlist[] = {"x", 0};
if (type != &PyFloat_Type)
return float_subtype_new(type, args, kwds); /* Wimp out */
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:float", kwlist, &x))
+ if (!_PyArg_NoKeywords("float()", kwds))
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 (!PyArg_UnpackTuple(args, "float", 0, 1, &x))
+ return NULL;
/* If it's a string, but not a string subclass, use
PyFloat_FromString. */
if (PyUnicode_CheckExact(x))
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 59f6881..473bd20 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -2293,16 +2293,11 @@
list_init(PyListObject *self, PyObject *args, PyObject *kw)
{
PyObject *arg = NULL;
- static char *kwlist[] = {"sequence", 0};
- if (!PyArg_ParseTupleAndKeywords(args, kw, "|O:list", kwlist, &arg))
+ if (!_PyArg_NoKeywords("list()", kw))
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;
- }
+ if (!PyArg_UnpackTuple(args, "list", 0, 1, &arg))
+ return -1;
/* Verify list invariants established by PyType_GenericAlloc() */
assert(0 <= Py_SIZE(self));
diff --git a/Objects/longobject.c b/Objects/longobject.c
index 6a5bc47..cfb4a3e 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -4796,7 +4796,7 @@
{
PyObject *obase = NULL, *x = NULL;
Py_ssize_t base;
- static char *kwlist[] = {"x", "base", 0};
+ static char *kwlist[] = {"", "base", 0};
if (type != &PyLong_Type)
return long_subtype_new(type, args, kwds); /* Wimp out */
@@ -4811,12 +4811,6 @@
}
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);
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index c2696c7..64db806 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -648,18 +648,13 @@
tuple_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
PyObject *arg = NULL;
- static char *kwlist[] = {"sequence", 0};
if (type != &PyTuple_Type)
return tuple_subtype_new(type, args, kwds);
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:tuple", kwlist, &arg))
+ if (!_PyArg_NoKeywords("tuple()", kwds))
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 (!PyArg_UnpackTuple(args, "tuple", 0, 1, &arg))
+ return NULL;
if (arg == NULL)
return PyTuple_New(0);