From 91fc8e2107d529676d79dd7dd0d37833d768bb65 Mon Sep 17 00:00:00 2001 From: Ian Wilson Date: Mon, 17 Jun 2024 16:35:23 -0700 Subject: [PATCH 1/2] Add test to document silent removal of bare * from defs. --- test/test_def.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/test_def.py b/test/test_def.py index fd96433..7782343 100644 --- a/test/test_def.py +++ b/test/test_def.py @@ -62,6 +62,25 @@ def test_def_py3k_args(self): """look at all these args: one two three four 5 seven""", ) + def test_def_py3k_args_quirk(self): + """Document quirk where bare * is silently removed which incorrectly + allows for kwonly args to be passed as positional. + + See issue #405 for more information.""" + template = Template( + """ + <%def name="kwonly(a, *, b)"> + hello kwonly: ${a} ${b} """ + """ + + + ${kwonly('1', '2')}""" + ) + eq_( + template.render().strip(), + """hello kwonly: 1 2""", + ) + def test_inter_def(self): """test defs calling each other""" template = Template( From 0ad95a26167788e2e57078986fb8ffd8ea33d3fe Mon Sep 17 00:00:00 2001 From: Ian Wilson Date: Mon, 17 Jun 2024 16:35:49 -0700 Subject: [PATCH 2/2] Add note to docs about silent removal of bare * from defs. --- doc/build/defs.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/build/defs.rst b/doc/build/defs.rst index 314e9b9..ca0f969 100644 --- a/doc/build/defs.rst +++ b/doc/build/defs.rst @@ -73,6 +73,10 @@ value). This is in contrast to using context-level variables, which evaluate to ``UNDEFINED`` if you reference a name that does not exist. +Note there is a quirk that results in a bare ``*`` being silently removed from +a function definition. The function then incorrectly +allows keyword only arguments to be used as positional arguments. + Calling Defs from Other Files -----------------------------