Skip to content

Commit

Permalink
cpp: improve fixed tuple validator
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthieuDartiailh committed Apr 16, 2024
1 parent c77f345 commit a5b1cee
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions atom/src/validatebehavior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,11 +493,6 @@ fixed_tuple_handler( Member* member, CAtom* atom, PyObject* oldvalue, PyObject*

// Create a copy in which to store the validated values
Py_ssize_t size = PyTuple_GET_SIZE( newvalue );
cppy::ptr tuplecopy = PyTuple_New( size );
if( !tuplecopy )
{
return 0;
}

// Check the size match the expected size
Py_ssize_t expected_size = PyTuple_GET_SIZE( member->validate_context );
Expand All @@ -515,6 +510,13 @@ fixed_tuple_handler( Member* member, CAtom* atom, PyObject* oldvalue, PyObject*
return 0;
}

// Create a new tuple to store the validate values
cppy::ptr tuplecopy = PyTuple_New( size );
if( !tuplecopy )
{
return 0;
}

// Validate each single item
for( Py_ssize_t i = 0; i < size; ++i )
{
Expand Down

0 comments on commit a5b1cee

Please sign in to comment.