Skip to content

Commit 03adaee

Browse files
rick68stefanseefeld
authored andcommitted
Implement str::endswith()
1 parent bc2f77a commit 03adaee

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/str.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,22 @@ bool str_base::endswith(object_cref suffix) const
162162
return result;
163163
}
164164

165+
bool str_base::endswith(object_cref suffix, object_cref start) const
166+
{
167+
bool result = _BOOST_PYTHON_ASLONG(this->attr("endswith")(suffix,start).ptr());
168+
if (PyErr_Occurred())
169+
throw_error_already_set();
170+
return result;
171+
}
172+
173+
bool str_base::endswith(object_cref suffix, object_cref start, object_cref end) const
174+
{
175+
bool result = _BOOST_PYTHON_ASLONG(this->attr("endswith")(suffix,start,end).ptr());
176+
if (PyErr_Occurred())
177+
throw_error_already_set();
178+
return result;
179+
}
180+
165181
BOOST_PYTHON_DEFINE_STR_METHOD(expandtabs, 0)
166182
BOOST_PYTHON_DEFINE_STR_METHOD(expandtabs, 1)
167183

0 commit comments

Comments
 (0)