Skip to content
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

Correctly detect presence of keyword parameters #46

Merged
merged 1 commit into from
Jul 9, 2017

Conversation

raboof
Copy link

@raboof raboof commented Jul 9, 2017

n_args doesn't count keyword (named) parameters, and it's possible to pass in
only some of those, so we need something else than n_args > x to check
whether a given keyword parameter is present.

MP_OBJ_IS_TYPE(MP_OBJ_NULL, &whatever) will crash, but
MP_OBJ_IS_TYPE(mp_const_none, &whatever) will always return 'false', so the
latter is a more suitable default for non-required keyword parameters.

See also caaf6ab

`n_args` doesn't count keyword (named) parameters, and it's possible to pass in
only some of those, so we need something else than `n_args > x` to check
whether a given keyword parameter is present.

`MP_OBJ_IS_TYPE(MP_OBJ_NULL, &whatever)` will crash, but
`MP_OBJ_IS_TYPE(mp_const_none, &whatever)` will always return 'false', so the
latter is a more suitable default for non-required keyword parameters.

See also caaf6ab
@raboof
Copy link
Author

raboof commented Jul 9, 2017

(reviewed by @aczid)

@raboof raboof merged commit a50aeeb into master Jul 9, 2017
@raboof raboof deleted the detectPresenceOfKeywordParameters branch July 9, 2017 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant