Skip to content

Disallow f(x, y=1, z) and similar nonsense#405

Merged
untitaker merged 1 commit intopallets:masterfrom
ThiefMaster:default-params-fix
Feb 6, 2015
Merged

Disallow f(x, y=1, z) and similar nonsense#405
untitaker merged 1 commit intopallets:masterfrom
ThiefMaster:default-params-fix

Conversation

@ThiefMaster
Copy link
Copy Markdown
Member

Python rejects such function definitions because it doesn't make much
sense to have arguments with no default values after arguments with
default values.

Jinja did allow them, but handled them improperly (associating the
default value with the wrong argument).

Due to how broken the current behavior is, it makes more sense to reject
templates containing such defintions instead of trying to handle them
properly. Both cases are going to break existing code containing such
definitions, but besides the fact that possibly no such code exists it
is better to fail with a clear error than to silently change the values
of arguments.

This fixes #364

Python rejects such function definitions because it doesn't make much
sense to have arguments with no default values after arguments with
default values.

Jinja did allow them, but handled them improperly (associating the
default value with the wrong argument).

Due to how broken the current behavior is, it makes more sense to reject
templates containing such defintions instead of trying to handle them
properly. Both cases are going to break existing code containing such
definitions, but besides the fact that possibly no such code exists it
is better to fail with a clear error than to silently change the values
of arguments.

This fixes pallets#364
untitaker added a commit that referenced this pull request Feb 6, 2015
Disallow f(x, y=1, z) and similar nonsense
@untitaker untitaker merged commit a0b863e into pallets:master Feb 6, 2015
@ThiefMaster ThiefMaster deleted the default-params-fix branch February 6, 2015 17:19
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default parameters aren't tracked properly

2 participants