bpo-41334: Convert constructors of str, bytes and bytearray to Argument Clinic (GH-21535)
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 7035061..8b57fb6 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -738,13 +738,20 @@
}
}
+/*[clinic input]
+bytearray.__init__
+
+ source as arg: object = NULL
+ encoding: str = NULL
+ errors: str = NULL
+
+[clinic start generated code]*/
+
static int
-bytearray_init(PyByteArrayObject *self, PyObject *args, PyObject *kwds)
+bytearray___init___impl(PyByteArrayObject *self, PyObject *arg,
+ const char *encoding, const char *errors)
+/*[clinic end generated code: output=4ce1304649c2f8b3 input=1141a7122eefd7b9]*/
{
- static char *kwlist[] = {"source", "encoding", "errors", 0};
- PyObject *arg = NULL;
- const char *encoding = NULL;
- const char *errors = NULL;
Py_ssize_t count;
PyObject *it;
PyObject *(*iternext)(PyObject *);
@@ -755,11 +762,6 @@
return -1;
}
- /* Parse arguments */
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oss:bytearray", kwlist,
- &arg, &encoding, &errors))
- return -1;
-
/* Make a quick exit if no first argument */
if (arg == NULL) {
if (encoding != NULL || errors != NULL) {
@@ -2354,7 +2356,7 @@
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
- (initproc)bytearray_init, /* tp_init */
+ (initproc)bytearray___init__, /* tp_init */
PyType_GenericAlloc, /* tp_alloc */
PyType_GenericNew, /* tp_new */
PyObject_Del, /* tp_free */