"""
self.expect_failure(block, err, lineno=8)
+ def test_multiple_star_in_args(self):
+ err = "'my_test_func' uses '*' more than once."
+ block = """
+ /*[clinic input]
+ my_test_func
+
+ pos_arg: object
+ *args: object
+ *
+ kw_arg: object
+ [clinic start generated code]*/
+ """
+ self.expect_failure(block, err, lineno=6)
+
def test_module_already_got_one(self):
err = "Already defined module 'm'!"
block = """
#endif
PyDoc_STRVAR(typevar_new__doc__,
-"typevar(name, *constraints, *, bound=None, covariant=False,\n"
+"typevar(name, *constraints, bound=None, covariant=False,\n"
" contravariant=False, infer_variance=False)\n"
"--\n"
"\n"
exit:
return return_value;
}
-/*[clinic end generated code: output=db0b327ebbb1488f input=a9049054013a1b77]*/
+/*[clinic end generated code: output=027fb8cbef6e5015 input=a9049054013a1b77]*/
name: object(subclass_of="&PyUnicode_Type")
*constraints: object
- *
bound: object = None
covariant: bool = False
contravariant: bool = False
typevar_new_impl(PyTypeObject *type, PyObject *name, PyObject *constraints,
PyObject *bound, int covariant, int contravariant,
int infer_variance)
-/*[clinic end generated code: output=1d200450ee99226d input=2c07ab87c94f462b]*/
+/*[clinic end generated code: output=1d200450ee99226d input=41ae33a916bfe76f]*/
{
if (covariant && contravariant) {
PyErr_SetString(PyExc_ValueError,
if version is None:
if self.keyword_only:
fail(f"Function {function.name!r} uses '*' more than once.")
+ self.check_previous_star()
self.check_remaining_star()
self.keyword_only = True
else:
fail(f"Function {self.function.name!r} specifies {symbol!r} "
f"without following parameters.", line_number=lineno)
+ def check_previous_star(self, lineno: int | None = None) -> None:
+ assert isinstance(self.function, Function)
+
+ for p in self.function.parameters.values():
+ if p.kind == inspect.Parameter.VAR_POSITIONAL:
+ fail(f"Function {self.function.name!r} uses '*' more than once.")
+
+
def do_post_block_processing_cleanup(self, lineno: int) -> None:
"""
Called when processing the block is done.