diff --git a/atom/src/member.cpp b/atom/src/member.cpp index 6a0c208d..99693ae8 100644 --- a/atom/src/member.cpp +++ b/atom/src/member.cpp @@ -458,7 +458,10 @@ parse_mode_and_context( PyObject*const *args, Py_ssize_t n, PyObject** context, { if( n != 2 ) + { + cppy::type_error( "set mode requires two arguments mode, context" ); return false; + } if( !EnumTypes::from_py_enum( args[0], mode ) ) return false; *context = args[1]; diff --git a/tests/test_get_behaviors.py b/tests/test_get_behaviors.py index b52bea33..94f361f4 100644 --- a/tests/test_get_behaviors.py +++ b/tests/test_get_behaviors.py @@ -174,3 +174,12 @@ class SlotAtom(Atom): with pytest.raises(AttributeError): SlotAtom.v.do_getattr(sa) + + +def test_using_invalid_args(): + """Test using the invalid arguments.""" + v = Value() + with pytest.raises(TypeError): + v.set_getattr_mode(None) + with pytest.raises(TypeError): + v.set_getattr_mode(7, None)