fix: Reject keyword argument None with .none(false) (#2611)

* demo kwarg with none(false)

* Reorder and extend tests for arg::none(false) in test_methods_and_attributes.py::test_accepts_none

* Fix arg::none() for keyword arguments

* Add changelog note

* Fix names of no_none_kw test functions

Co-authored-by: Yannick Jadoul <yannick.jadoul@belgacom.net>
This commit is contained in:
Mana Borwornpadungkitti
2020-10-20 17:57:22 -04:00
committed by GitHub
parent 7f9445a626
commit 6edd0e6d90
4 changed files with 34 additions and 11 deletions

View File

@@ -336,6 +336,9 @@ TEST_SUBMODULE(methods_and_attributes, m) {
m.def("ok_none4", &none4, py::arg().none(true));
m.def("ok_none5", &none5);
m.def("no_none_kwarg", &none2, py::arg("a").none(false));
m.def("no_none_kwarg_kw_only", &none2, py::kw_only(), py::arg("a").none(false));
// test_str_issue
// Issue #283: __str__ called on uninitialized instance when constructor arguments invalid
py::class_<StrIssue>(m, "StrIssue")