-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
gh-131652: remove duplicated bits in Lib/test/clinic.test.c
#131653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4198,44 +4198,6 @@ static PyObject * | |
test_vararg_and_posonly_impl(PyObject *module, PyObject *a, PyObject *args) | ||
/*[clinic end generated code: output=0c11c475e240869e input=2c49a482f68545c0]*/ | ||
|
||
PyDoc_STRVAR(test_vararg_and_posonly__doc__, | ||
"test_vararg_and_posonly($module, a, /, *args)\n" | ||
"--\n" | ||
"\n"); | ||
|
||
#define TEST_VARARG_AND_POSONLY_METHODDEF \ | ||
{"test_vararg_and_posonly", _PyCFunction_CAST(test_vararg_and_posonly), METH_FASTCALL, test_vararg_and_posonly__doc__}, | ||
|
||
static PyObject * | ||
test_vararg_and_posonly_impl(PyObject *module, PyObject *a, Py_ssize_t nargs, | ||
PyObject *const *args); | ||
|
||
static PyObject * | ||
test_vararg_and_posonly(PyObject *module, PyObject *const *args, Py_ssize_t nargs) | ||
{ | ||
PyObject *return_value = NULL; | ||
Py_ssize_t nvararg = nargs - 1; | ||
PyObject *a; | ||
PyObject *const *__clinic_args = NULL; | ||
|
||
if (!_PyArg_CheckPositional("test_vararg_and_posonly", nargs, 1, PY_SSIZE_T_MAX)) { | ||
goto exit; | ||
} | ||
a = args[0]; | ||
__clinic_args = _PyTuple_FromArray(args + 1, nargs - 1); | ||
if (__clinic_args == NULL) { | ||
goto exit; | ||
} | ||
return_value = test_vararg_and_posonly_impl(module, a, nvararg, __clinic_args); | ||
|
||
exit: | ||
/* Cleanup for args */ | ||
Py_XDECREF(__clinic_args); | ||
|
||
return return_value; | ||
} | ||
|
||
|
||
/*[clinic input] | ||
test_vararg | ||
|
||
|
@@ -5045,39 +5007,6 @@ static int | |
Test___init___impl(TestObj *self, PyObject *args) | ||
/*[clinic end generated code: output=f172425cec373cd6 input=4b8388c4e6baab6f]*/ | ||
|
||
PyDoc_STRVAR(Test___init____doc__, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @erlend-aasland You added this back in ec45c51 but I don't know why there is a duplicated entry, one generated by clinic and one that is not. Note that the one generated by clinic has been changed since then while the non-clinic one hasn't change (and I think the docstring is now outdated for the clinic one). |
||
"Test(*args)\n" | ||
"--\n" | ||
"\n" | ||
"Varargs init method. For example, nargs is translated to PyTuple_GET_SIZE."); | ||
|
||
static int | ||
Test___init___impl(TestObj *self, Py_ssize_t nargs, PyObject *const *args); | ||
|
||
static int | ||
Test___init__(PyObject *self, PyObject *args, PyObject *kwargs) | ||
{ | ||
int return_value = -1; | ||
PyTypeObject *base_tp = TestType; | ||
PyObject *const *__clinic_args = NULL; | ||
|
||
if ((Py_IS_TYPE(self, base_tp) || | ||
Py_TYPE(self)->tp_new == base_tp->tp_new) && | ||
!_PyArg_NoKeywords("Test", kwargs)) { | ||
goto exit; | ||
} | ||
__clinic_args = Py_NewRef(args); | ||
return_value = Test___init___impl((TestObj *)self, nvararg, __clinic_args); | ||
|
||
exit: | ||
/* Cleanup for args */ | ||
Py_XDECREF(__clinic_args); | ||
|
||
return return_value; | ||
} | ||
|
||
|
||
|
||
/*[clinic input] | ||
@classmethod | ||
Test.__new__ | ||
|
@@ -5120,37 +5049,6 @@ static PyObject * | |
Test_impl(PyTypeObject *type, PyObject *args) | ||
/*[clinic end generated code: output=ee1e8892a67abd4a input=a8259521129cad20]*/ | ||
|
||
PyDoc_STRVAR(Test__doc__, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto for this block @erlend-aasland |
||
"Test(*args)\n" | ||
"--\n" | ||
"\n" | ||
"Varargs new method. For example, nargs is translated to PyTuple_GET_SIZE."); | ||
|
||
static PyObject * | ||
Test_impl(PyTypeObject *type, Py_ssize_t nargs, PyObject *const *args); | ||
|
||
static PyObject * | ||
Test(PyTypeObject *type, PyObject *args, PyObject *kwargs) | ||
{ | ||
PyObject *return_value = NULL; | ||
PyTypeObject *base_tp = TestType; | ||
PyObject *const *__clinic_args = NULL; | ||
|
||
if ((type == base_tp || type->tp_init == base_tp->tp_init) && | ||
!_PyArg_NoKeywords("Test", kwargs)) { | ||
goto exit; | ||
} | ||
__clinic_args = Py_NewRef(args); | ||
return_value = Test_impl(type, nvararg, __clinic_args); | ||
|
||
exit: | ||
/* Cleanup for args */ | ||
Py_XDECREF(__clinic_args); | ||
|
||
return return_value; | ||
} | ||
|
||
|
||
|
||
/*[clinic input] | ||
Test.__init__ | ||
|
@@ -6018,37 +5916,6 @@ static PyObject * | |
test_critical_section_object_impl(PyObject *module, PyObject *a) | ||
/*[clinic end generated code: output=ec06df92232b0fb5 input=6f67f91b523c875f]*/ | ||
|
||
PyDoc_STRVAR(test_critical_section_object__doc__, | ||
"test_critical_section_object($module, a, /)\n" | ||
"--\n" | ||
"\n" | ||
"test_critical_section_object"); | ||
|
||
#define TEST_CRITICAL_SECTION_OBJECT_METHODDEF \ | ||
{"test_critical_section_object", (PyCFunction)test_critical_section_object, METH_O, test_critical_section_object__doc__}, | ||
|
||
static PyObject * | ||
test_critical_section_object_impl(PyObject *module, PyObject *a); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
static PyObject * | ||
test_critical_section_object(PyObject *module, PyObject *arg) | ||
{ | ||
PyObject *return_value = NULL; | ||
PyObject *a; | ||
|
||
if (!PyUnicode_Check(arg)) { | ||
_PyArg_BadArgument("test_critical_section_object", "argument", "str", arg); | ||
goto exit; | ||
} | ||
a = arg; | ||
Py_BEGIN_CRITICAL_SECTION(a); | ||
return_value = test_critical_section_object_impl(module, a); | ||
Py_END_CRITICAL_SECTION(); | ||
|
||
exit: | ||
return return_value; | ||
} | ||
|
||
/*[clinic input] | ||
@critical_section a b | ||
test_critical_section_object2 | ||
|
@@ -6103,44 +5970,3 @@ static PyObject * | |
test_critical_section_object2_impl(PyObject *module, PyObject *a, | ||
PyObject *b) | ||
/*[clinic end generated code: output=d73a1657c18df17a input=638824e41419a466]*/ | ||
|
||
PyDoc_STRVAR(test_critical_section_object2__doc__, | ||
"test_critical_section_object2($module, a, b, /)\n" | ||
"--\n" | ||
"\n" | ||
"test_critical_section_object2"); | ||
|
||
#define TEST_CRITICAL_SECTION_OBJECT2_METHODDEF \ | ||
{"test_critical_section_object2", _PyCFunction_CAST(test_critical_section_object2), METH_FASTCALL, test_critical_section_object2__doc__}, | ||
|
||
static PyObject * | ||
test_critical_section_object2_impl(PyObject *module, PyObject *a, | ||
PyObject *b); | ||
|
||
static PyObject * | ||
test_critical_section_object2(PyObject *module, PyObject *const *args, Py_ssize_t nargs) | ||
{ | ||
PyObject *return_value = NULL; | ||
PyObject *a; | ||
PyObject *b; | ||
|
||
if (!_PyArg_CheckPositional("test_critical_section_object2", nargs, 2, 2)) { | ||
goto exit; | ||
} | ||
if (!PyUnicode_Check(args[0])) { | ||
_PyArg_BadArgument("test_critical_section_object2", "argument 1", "str", args[0]); | ||
goto exit; | ||
} | ||
a = args[0]; | ||
if (!PyUnicode_Check(args[1])) { | ||
_PyArg_BadArgument("test_critical_section_object2", "argument 2", "str", args[1]); | ||
goto exit; | ||
} | ||
b = args[1]; | ||
Py_BEGIN_CRITICAL_SECTION2(a, b); | ||
return_value = test_critical_section_object2_impl(module, a, b); | ||
Py_END_CRITICAL_SECTION2(); | ||
|
||
exit: | ||
return return_value; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@skirpichev You added this one in 8c22eba but it already existed above. Can you explain what you wanted to test here please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, but both functions existed before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but maybe you knew why they were duplicated ...