Skip to content

Commit 338630c

Browse files
authored
Merge pull request #238 from frmdstryr/parse-mode-error
Return error if num args is incorrect in parse_mod_and_context
2 parents 54adc3f + caa2911 commit 338630c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

atom/src/member.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,10 @@ parse_mode_and_context( PyObject*const *args, Py_ssize_t n, PyObject** context,
458458
{
459459

460460
if( n != 2 )
461+
{
462+
cppy::type_error( "set mode requires two arguments mode, context" );
461463
return false;
464+
}
462465
if( !EnumTypes::from_py_enum( args[0], mode ) )
463466
return false;
464467
*context = args[1];

tests/test_get_behaviors.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,12 @@ class SlotAtom(Atom):
174174

175175
with pytest.raises(AttributeError):
176176
SlotAtom.v.do_getattr(sa)
177+
178+
179+
def test_using_invalid_args():
180+
"""Test using the invalid arguments."""
181+
v = Value()
182+
with pytest.raises(TypeError):
183+
v.set_getattr_mode(None)
184+
with pytest.raises(TypeError):
185+
v.set_getattr_mode(7, None)

0 commit comments

Comments
 (0)