mirror of
https://github.com/pybind/pybind11.git
synced 2026-03-14 20:27:47 +00:00
fix: enable py::implicitly_convertible<py::none, ...> for py::class_-wrapped types (#3059)
* Allow casting from None to a custom object, closes #2778 * ci.yml patch from the smart_holder branch for full CI coverage.
This commit is contained in:
@@ -431,6 +431,17 @@ def test_accepts_none(msg):
|
||||
assert "incompatible function arguments" in str(excinfo.value)
|
||||
|
||||
|
||||
def test_casts_none(msg):
|
||||
"""#2778: implicit casting from None to object (not pointer)"""
|
||||
a = m.NoneCastTester()
|
||||
assert m.ok_obj_or_none(a) == -1
|
||||
a = m.NoneCastTester(4)
|
||||
assert m.ok_obj_or_none(a) == 4
|
||||
a = m.NoneCastTester(None)
|
||||
assert m.ok_obj_or_none(a) == -1
|
||||
assert m.ok_obj_or_none(None) == -1
|
||||
|
||||
|
||||
def test_str_issue(msg):
|
||||
"""#283: __str__ called on uninitialized instance when constructor arguments invalid"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user