Skip to content

Commit

Permalink
Merge pull request #238 from frmdstryr/parse-mode-error
Browse files Browse the repository at this point in the history
Return error if num args is incorrect in parse_mod_and_context
  • Loading branch information
sccolbert authored Jan 21, 2025
2 parents 54adc3f + caa2911 commit 338630c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions atom/src/member.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
9 changes: 9 additions & 0 deletions tests/test_get_behaviors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 338630c

Please sign in to comment.