summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-03-06 15:01:06 (GMT)
committerGitHub <noreply@github.com>2017-03-06 15:01:06 (GMT)
commit2e5642422f6234fd8d0c082142b27340e588f96e (patch)
tree8279099d6fc0b034aaeb0be40a1d30d9246afc81 /Objects
parentb76ad5121e2cfa89d6476d700cbcb65b7ffc39ac (diff)
downloadcpython-2e5642422f6234fd8d0c082142b27340e588f96e.zip
cpython-2e5642422f6234fd8d0c082142b27340e588f96e.tar.gz
cpython-2e5642422f6234fd8d0c082142b27340e588f96e.tar.bz2
bpo-29695: Remove bad keyword parameters in int(), bool(), float(), list() and tuple(). (#518)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/boolobject.c11
-rw-r--r--Objects/floatobject.c11
-rw-r--r--Objects/listobject.c11
-rw-r--r--Objects/longobject.c8
-rw-r--r--Objects/tupleobject.c11
5 files changed, 13 insertions, 39 deletions
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 @@ PyObject *PyBool_FromLong(long ok)
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 (!PyArg_UnpackTuple(args, "bool", 0, 1, &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;
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 @@ static PyObject *
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 (!PyArg_UnpackTuple(args, "float", 0, 1, &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))
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 @@ static int
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 (!PyArg_UnpackTuple(args, "list", 0, 1, &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));
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 @@ long_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
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 @@ 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);
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 @@ static PyObject *
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 (!PyArg_UnpackTuple(args, "tuple", 0, 1, &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);