gh-114258: Argument Clinic: refactor getset implementation (#116170)

* Move param guard to param state machine
* Override return converter during parsing
* Don't use a custom type slot return converter; instead
  special case type slot functions during generation.
This commit is contained in:
Erlend E. Aasland 2024-03-04 13:51:28 +01:00 committed by GitHub
parent 45a92436c5
commit cfbdce7208
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 35 deletions

View file

@ -5004,12 +5004,16 @@ Test_property_set_impl(TestObj *self, PyObject *value);
static int
Test_property_set(TestObj *self, PyObject *value, void *Py_UNUSED(context))
{
return Test_property_set_impl(self, value);
int return_value;
return_value = Test_property_set_impl(self, value);
return return_value;
}
static int
Test_property_set_impl(TestObj *self, PyObject *value)
/*[clinic end generated code: output=9797cd03c5204ddb input=3bc3f46a23c83a88]*/
/*[clinic end generated code: output=d51023f17c4ac3a1 input=3bc3f46a23c83a88]*/
/*[clinic input]
output push
@ -5327,11 +5331,6 @@ Test__pyarg_parsestackandkeywords_impl(TestObj *self, PyTypeObject *cls,
/*[clinic end generated code: output=4fda8a7f2547137c input=fc72ef4b4cfafabc]*/
static long
Test___init___impl(TestObj *self)
/*[clinic end generated code: output=daf6ee12c4e443fb input=311af0dc7f17e8e9]*/
/*[clinic input]
fn_with_default_binop_expr
arg: object(c_default='CONST_A + CONST_B') = a+b

View file

@ -2175,7 +2175,7 @@ class Foo "" ""
obj: int
/
"""
expected_error = f"{annotation} method cannot define parameters"
expected_error = f"{annotation} methods cannot define parameters"
self.expect_failure(block, expected_error)
def test_setter_docstring(self):
@ -2655,7 +2655,6 @@ def test_cli_converters(self):
bool()
double()
float()
init()
int()
long()
Py_ssize_t()
@ -3945,7 +3944,7 @@ def test_Function_and_Parameter_reprs(self):
cls=None,
c_basename=None,
full_name='foofoo',
return_converter=clinic.init_return_converter(),
return_converter=clinic.int_return_converter(),
kind=clinic.FunctionKind.METHOD_INIT,
coexist=False
)